Ticket template as drop-down

Moderator: crythias

Locked
Erwing
Znuny newbie
Posts: 16
Joined: 03 Jan 2011, 15:40
Znuny Version: 2.4.5

Ticket template as drop-down

Post by Erwing »

Hi

I have been looking at the possibility to use a drop-down box for populating a (for instance) PhoneTicket

I see in the AgentTicketPhone.dtl (and http://www.youtube.com/watch?v=1B8mZ9Ku ... ideo_title & http://blog.otrs.org/2010/11/02/otrs-3- ... templates/) that there is example code to create templates for this

However, the example shows this pressing a button, wheras I would like to use a dropdown, and let that populate the ticket fields

How would I go about changing thie below code (found in AgentTicketPhone.dtl) which works when pressing a button, to work with a drop-down instead?

Code: Select all

# example template for customizations, see hidden form at the end of the file
<label>$Text{"Templates"}:</label>
    <div class="Field">
           <button type="button" onclick="$('#Template1').submit()" value="$Text{"Example Template"}">$Text{"Example Template"}</button>
    </div>
    <div class="Clear"></div>

# example template form for customizations
<form action="$Env{"CGIHandle"}" method="post" enctype="multipart/form-data" id="Template1">
    <input type="hidden" name="Action" value="$Env{"Action"}"/>
    <input type="hidden" name="Subaction" value="StoreNew"/>
    <input type="hidden" name="FormID" value="$QData{"FormID"}"/>
    <input type="hidden" name="ExpandCustomerName" value="2"/>
    <input type="hidden" name="Subject" value="Example Subject"/>
    <input type="hidden" name="Body" value="Name:
Product:
Comment:"/>
</form>
--- Erwing
OTRS 3.2.2 on CentOS - mySQL
Erwing
Znuny newbie
Posts: 16
Joined: 03 Jan 2011, 15:40
Znuny Version: 2.4.5

Re: Ticket template as drop-down

Post by Erwing »

Hi again - no one who has any tips or guidelines?

In the meantime, I found this: http://otrs9.org/day3#extension - more info here: http://opar.perl-services.de/bin/index. ... etTemplate

It works, even if the creation of the templates is somewhat tedious (you know it if you try it). However, there is only one showstopper as far as I can see
When it comes to the body of the template (the actual text in the RichTextEditor) - it does not seem to hold any of the formatting

I.e. if I have some text like this in the body

- A line of text:
- Another line of text:
- A third line of text:

The template then returns "- A line of text: - Another line of text: - A third line of text:" in the body under ticket creation
I have even tried setting the body using the "source" and with "<br>", but still nothing

Has anyone tried using the above opm and managed to get linebreaks??

--- Erwing
OTRS 3.2.2 on CentOS - mySQL
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: Ticket template as drop-down

Post by renee »

The development of TicketTemplate is stalled at the moment as the OTRS Community Board announced the development of tidbit: http://forums.otrs.org/viewtopic.php?f= ... 77&p=44351

Unfortunately, I won't have time to look at the issue until October 2nd, as I'm really busy till then. If anybody can provide a patch, I can create a new release (or make you a co-maintainer in OPAR). I can create a github repository if needed.
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Ticket template as drop-down

Post by crythias »

did you try \n ?
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
Erwing
Znuny newbie
Posts: 16
Joined: 03 Jan 2011, 15:40
Znuny Version: 2.4.5

Re: Ticket template as drop-down

Post by Erwing »

crythias wrote:did you try \n ?
Hi - I had not tried, but did just now - does not seem to work

I might be doing it wrong - but I press the "source" button, then type some lines with the \n, it does not seem to do anything

Any more input for the community?

--- Erwing
OTRS 3.2.2 on CentOS - mySQL
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Ticket template as drop-down

Post by crythias »

You might take a look at my howto http://forums.otrs.org/viewtopic.php?f=60&t=8032 for a different hint.
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
Erwing
Znuny newbie
Posts: 16
Joined: 03 Jan 2011, 15:40
Znuny Version: 2.4.5

[SOLVED] Re: Ticket template as drop-down

Post by Erwing »

Hi

Just wanted to throw in a line here again, as I have managed to solve this (its not a very sexy solution, but it works for my needs as of now)

In the file AgentTicketPhone.dtl, there is example code at the end of the file for populating the form, dependent on a button click. The example code for the button is also in the file (commented out)

I first built different forms based on the example form, and then added in the following code below the example code that creates the "template button" (this was commented out)

Code: Select all

<label>$Text{"Templates"}:</label>
                    <div class="Field">
                        <form>
                        <select id="setemplates" size="1">
                        <option value="nothing" selected="selected">Select template</option>
                        <option value="Template1">Template 1</option>
                        <option value="Template2">Template 2</option>
                        </select>
                        </form>
                    </div>
                    <div class="Clear"></div>
This creates a dropdown box with two templates

Then I added the following JS just above the "Template forms"

Code: Select all

<script type="text/javascript">
var selectmenu=document.getElementById("setemplates")
selectmenu.onchange=function(){ //run some code when "onchange" event fires
        var chosenoption=this.options[this.selectedIndex] //this refers to "selectmenu"
        if (chosenoption.value!="nothing"){
                document.getElementById(chosenoption.value).submit();
        }
}
</script>
I can now let my agents populate the ticket quickly depending on what kind of category the customer calls in about

Please comment on the solution if anyone has any ideas as to how take this furher

-- Erwing
OTRS 3.2.2 on CentOS - mySQL
Giulio Soleni
Znuny wizard
Posts: 392
Joined: 30 Dec 2010, 14:35
Znuny Version: 6.0.x and 5.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: Ticket template as drop-down

Post by Giulio Soleni »

Hallo Erwing,
I am trying your solution and it's quite good... but I noticed one annoyng side effect:
after I selected my template (which in my case also prefills the "To queue" field), as soon as I select the customer in the "From customer" field, the "Next ticket state" field and the "Priority" field get reset to their lower id value (that in my case are "Closed successful" for the state and "1 very low" for the priority) ... so I have to remember every time I open a ticket for a customer, to reset both this field manually to their default values (open and normal).

Beside this fact, your solution seems to work pretty good... however I'd rather to have a preset of the various fields as soon as I select the queue, without a specific "Template" selection... that is a feature similar to the one described by crythias for the Customer Interface (http://forums.otrs.org/viewtopic.php?f=60&t=8032)
OTRS 6.0.x on CentOS 7.x with MariaDB 10.2.x database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.
bamber01
Znuny newbie
Posts: 2
Joined: 26 Jul 2012, 11:28
Znuny Version: 3.0.5
Real Name: Andrew Gascoyne
Company: European Southern Observatory

Re: Ticket template as drop-down

Post by bamber01 »

Thanks for your help, this works really well for us, and I am now popultaing the template button with many many templates:)
Locked