OTRS – Adding Templates to OTRS

OTRS — Jeff Eske on February 6, 2012 at 3:51 pm

We’re currently investigating using OTRS, with the ITSM modules, as a possible ticketing system.  In version 3.0, they’ve got the ability to add ticket templates.  Templates are nice in that they allow you to create semi-complete tickets just by choosing a template.  That is one of the features that FrontRange’s ITSM product have in Version 7 that we were really looking forward to having.  Currently, in FRS’s ITSM (version 6) we’re using QuickActions to do basically the same thing.

There is a great Youtube video that describes what to do to get templates working in the default form.   The problem is that the example template code that OTRS has in the AgentTicketPhone.dtl file discussed uses a button to choose the template text.  That’s all well and fine for some browsers, but doesn’t work in all of them, due to using the onclick function.  Seems that Safari and some other browsers just ignore that. Plus, in my opinion, it would be pretty ugly, and reminiscent of a 1990’s webpage, to have a dozen different buttons to click on.  Maybe if they were each a different color and blinked…

Anyway, after some Trial and Error, I was able to get a cleaner method working – in IE, Firefox, Safari, and other browsers.  I replaced the button(s) with a dropdown menu.  This is simply a select tag, with an option representing each template form.  It then uses the onchange function, rather than the onclick function, fire off the appropriate form.  This means that all of the major browsers seem to be all right with it.  I tested it in IE, Firefox, Opera, Safari, and Chrome and they all worked as expected.

What I’ve done is create a custom theme, then copied and altered the AgentTicketPhone.dtl file to add my changes.  This means that during upgrades, my changes won’t be overwritten, since they’re not made in the default file.

Anyway, the way the example is written in the file is:

As you can see, it uses the onclick function and each template would require its own button.

What I’ve done, is add a dropdown via the select tag and its options and used the onchange function:

Things to note are:

1> Make sure to add the id=”some_name” to your select tag, or the GetElementByID() won’t work, since there won’t be an ID to get.

2> The option values are actually the names of each form that I’ve added at the bottom of the page.  That means that there’s a form at the bottom with id=”PassReset” and one with id=”VirusMalware”.   These forms contain the fields and values that you want to use to automagically populate the ticket.  Changing the fields and values is covered in the video.


This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. | Jeff's Meanderings*