Assign a Queue when choosing a Service

Moderator: crythias

Post Reply
hinatus
Znuny newbie
Posts: 3
Joined: 15 Oct 2019, 11:29
Znuny Version: 6.0.17
Real Name: Dilmar

Assign a Queue when choosing a Service

Post by hinatus »

Hello everyone!
My trouble in AgentTicketPhone.tt.
I want that when choosing a Service immediately select the value of the Queue.
I read all these topics
How To show freetext for specific Queues for Customers
How To Show/Hide Dynamic Field for specific Queue
but could not solve this problem.
This is my code:

Code: Select all

[% RenderBlockStart("TicketService") %]
                    [% IF Data.ServiceMandatory %]
                        <label class="Mandatory" for="ServiceID"><span class="Marker">*</span> [% Translate("Service") | html %]:</label>
                    [% ELSE %]
                        <label for="ServiceID">[% Translate("Service") | html %]:</label>
                    [% END %]
                    <div class="Field">
                        [% Data.ServiceStrg %]
                        [% IF Data.ServiceMandatory %]
                            <div id="ServiceIDError" class="TooltipErrorMessage" ><p>[% Translate("This field is required.") | html %]</p></div>
                        [% END %]
                        <div id="ServiceIDServerError" class="TooltipErrorMessage"><p>[% Translate("Service invalid.") | html %]</p></div>
                    </div>
                    <div class="Clear"></div>
                    
                    
					[% WRAPPER JSOnDocumentComplete %]
<script type="text/javascript">//<![CDATA[
$(document).ready(function() {
    function selectQueues() {
        switch ($('#ServiceID').val() ) {
         case  "2":
	       document.getElementById("Dest").value = '3||Junk';
		  break;   
         default: 
        } // End switch	
	} // End selectQueues
	
    $('#ServiceID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'ServiceID', ['TypeID', 'PriorityID', 'Dest', 'SLAID', [% Data.DynamicFieldNamesStrg %]]);
        selectQueues();
    });

    selectQueues();

}); // End document ready


//]]></script>
[% END %]
[% RenderBlockEnd("TicketService") %]
best regards,
Dilmar.
Last edited by hinatus on 16 Oct 2019, 13:28, edited 1 time in total.
Debian GNU/Linux 9.5, OTRS 6.0.17
hinatus
Znuny newbie
Posts: 3
Joined: 15 Oct 2019, 11:29
Znuny Version: 6.0.17
Real Name: Dilmar

Re: Assign a Queue when choosing a Service

Post by hinatus »

If i put document.getElementById("Dest").value = '3||Junk'; above, For example:

Code: Select all

[% WRAPPER JSOnDocumentComplete %]
<script type="text/javascript">//<![CDATA[

$(document).ready(function() {

  document.getElementById("Dest").value = '3||Junk';
    	 
I see that the Queue field is still empty, but the value is selected there.But I need it to be assigned.

thank you in advance
Debian GNU/Linux 9.5, OTRS 6.0.17
zzz
Znuny superhero
Posts: 889
Joined: 15 Dec 2016, 15:13
Znuny Version: All
Real Name: Emin
Company: Efflux GmbH
Contact:

Re: Assign a Queue when choosing a Service

Post by zzz »

Hello Dilmar,

You also have to trigger the change event on manual changes. Try this one:

Code: Select all

$('#Dest').val('3||Junk').trigger('change');
Best regards
Emin
Professional OTRS, Znuny & OTOBO services: efflux.de | efflux.de/en/

Free and premium add-ons: German | English
hinatus
Znuny newbie
Posts: 3
Joined: 15 Oct 2019, 11:29
Znuny Version: 6.0.17
Real Name: Dilmar

Re: Assign a Queue when choosing a Service

Post by hinatus »

Thanks zzz! it's work!
But i see that this does not always work (8/10). Sometimes the value does not appear.
Debian GNU/Linux 9.5, OTRS 6.0.17
zzz
Znuny superhero
Posts: 889
Joined: 15 Dec 2016, 15:13
Znuny Version: All
Real Name: Emin
Company: Efflux GmbH
Contact:

Re: Assign a Queue when choosing a Service

Post by zzz »

Hm it's hard to reproduce a remote client-side error.
Try to add a delay to see if the queue change happens before the last AJAX-call and shorten the time if it helps (or even better: react to the last change/AJAX-call).

Code: Select all

setTimeout(function() {
  $('#Dest').val('3||Junk').trigger('change');
}, 2000);  // Wait 2 seconds.
Best regards
Emin
Professional OTRS, Znuny & OTOBO services: efflux.de | efflux.de/en/

Free and premium add-ons: German | English
Post Reply