Ticket template based on selected Service

Moderator: crythias

Post Reply
Mothra
Znuny expert
Posts: 189
Joined: 26 Oct 2010, 15:04
Znuny Version: 3.2.11

Ticket template based on selected Service

Post by Mothra »

I'm looking into the possibility of having the Subject and Body of a ticket populated with text after selecting a particular Service. In my set-up, the list of services is in turn only populated after selecting a customer name. At this point in the source, I see this is a simple HTML select tag with options, which is presumably generated somewhere I haven't yet discovered.

What I'd like is to modify these Service options to act in the same way the commented out template button works in AgentTicketPhone.dtl, i.e. with an onclick event that calls the appropriate template. Is it possible to do this without breaking too much?
OTRS 3.2.11 on Centos 6.4 with MySQL 5.0. Agents and internal customers authenticate via Active Directory.
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Ticket template based on selected Service

Post by crythias »

Welcome back :)

http://forums.otrs.org/viewtopic.php?f=60&t=8032#p43215 should help (change the location from TypeID to Service(something))
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Mothra
Znuny expert
Posts: 189
Joined: 26 Oct 2010, 15:04
Znuny Version: 3.2.11

Re: Ticket template based on selected Service

Post by Mothra »

My OTRS skills are a bit rusty - I tried the following, but it doesn't seem to populate the body text area as I was expecting:

Code: Select all

    $('#ServiceID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'ServiceID', ['NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'SLAID', 'SignKeyID', 'CryptKeyID', 'TicketFreeText1', 'TicketFreeText2', 'TicketFreeText3', 'TicketFreeText4', 'TicketFreeText5', 'TicketFreeText6', 'TicketFreeText7', 'TicketFreeText8', 'TicketFreeText9', 'TicketFreeText10', 'TicketFreeText11', 'TicketFreeText12', 'TicketFreeText13', 'TicketFreeText14', 'TicketFreeText15', 'TicketFreeText16', 'To', 'Cc', 'Bcc']);

# Change body based on selected Service
    switch ($('#ServiceID').val() ) {
    case "1":
      document.compose.RichText.value = "Text for Service 1";
    break;
    case "2":
      document.compose.RichText.value = "Text for Service 2";
    break;
    default:
      document.compose.RichText.value = $('#ServiceID').val();
    }

    });
//]]></script>
<!--dtl:js_on_document_complete-->
OTRS 3.2.11 on Centos 6.4 with MySQL 5.0. Agents and internal customers authenticate via Active Directory.
Mothra
Znuny expert
Posts: 189
Joined: 26 Oct 2010, 15:04
Znuny Version: 3.2.11

Re: Ticket template based on selected Service

Post by Mothra »

Hmmm, it seems to work when I change the lines to document.compose.Subject.value = "Text for Service 1";

So it seems that RichText is not the right name when applying this to AgentTicketPhone.dtl or AgentTicketEmail.dtl (and I didn't mention that in the OP... apologies for that).
OTRS 3.2.11 on Centos 6.4 with MySQL 5.0. Agents and internal customers authenticate via Active Directory.
Mothra
Znuny expert
Posts: 189
Joined: 26 Oct 2010, 15:04
Znuny Version: 3.2.11

Re: Ticket template based on selected Service

Post by Mothra »

... and if I switch off the RichText editor in Framework -> Core::Web... I can populate both Subject and Body with:

Code: Select all

    case "1":
      document.compose.Subject.value = "Text for Service 1";
      document.compose.RichText.value = "Service 1 Values<br>more text";
    break;
Although it prints the RichText.value literally.

Going to raise this problem separately in the Help section.
OTRS 3.2.11 on Centos 6.4 with MySQL 5.0. Agents and internal customers authenticate via Active Directory.
Post Reply