How To show freetext for specific Queues for Customers

Dont create your support topics here! No new topics with questions allowed!

Moderator: crythias

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

How To show freetext for specific Queues for Customers

Post by crythias » 05 Feb 2011, 05:03

Version 3.3 Users Should check here
What does this do? It shows things like FreeTextFields to customers based upon the queue they choose. It's client-side and relies on CSS to hide elements. Also, this code shows you how you can change the body based upon the queue.

Edit Kernel/Output/HTML/Standard (or your theme! recommended!)/CustomerTicketMessage.dtl

This was a fun thing. It's not perfect, and you should test things out before going live, but take a look:
A while ago I submitted this: http://forums.otrs.org/viewtopic.php?f=62&t=5157#p23375

But, let's see if we can make a Free Text field show up only on certain queues...

I have sneaky way of doing it. Let's say js actually works...

Code: Select all

<script type="text/javascript">
    Core.Customer.InitFocus();
//above two lines are already there
    switch ($('#Dest').val() ) { //this is where the queue is relevant (Dest = Queue)
    case  "3\|\|Junk": // need to slash escape the pipes
      document.compose.RichText.value = "This is junk<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      document.getElementById('TicketFreeText1').style.display = 'block';
      document.getElementById('LabelTicketFreeText1').style.display = 'block';
    break;
    default:
      document.compose.RichText.value = $('#Dest').val(); //remove this. debug only. shows queue information
      document.getElementById('TicketFreeText1').style.display = 'none';
      document.getElementById('LabelTicketFreeText1').style.display = 'none';
    }
// the following two lines are the existing last two lines of CustomerTicketMessage.dtl 
</script>
<!-- dtl:js_on_document_complete -->
NOTE: if the free text fields are REQUIRED, there's additional work to be done, but this is a workaround if you want to display only on certain queues.

*similar* entries can be made in AgentTicketPhone.dtl and AgentTicketEmail.dtl (maybe not, but check this post: http://blog.otrs.org/2010/11/02/otrs-3- ... templates/)

PLEASE ask questions. DO NOT copy this stuff verbatim. You're going to get javascript errors if you try to address FreeText fields or queues or elements that don't exist/aren't enabled in sysconfig.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

nelsonsirait
OTRS newbie
Posts: 2
Joined: 08 Mar 2011, 12:36
OTRS Version?: 3.0.5

Re: How To show freetext for specific Queues for Customers

Post by nelsonsirait » 08 Mar 2011, 12:41

Hi Crythias,

Thanks for the info but as i'm new in OTRS and I want to display freetext field only for certain queue.
Could you please to explain the step by step what value should i put on the script?

Thanks in advance..

Nelson.

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 08 Mar 2011, 13:20

change the case statement to represent your queue information. Change the FreeText number to represent the field(s) you want to show for that queue. You can get the queue ID from the URL link to the queue.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

nelsonsirait
OTRS newbie
Posts: 2
Joined: 08 Mar 2011, 12:36
OTRS Version?: 3.0.5

Re: How To show freetext for specific Queues for Customers

Post by nelsonsirait » 10 Mar 2011, 10:19

Crithyas,

Thanks and it's work...i can use it with my OTRS 3.0.5
Actually now i just use the script to create Text Template that should show in the body of certain queue..
For example: I need when user choose a queue let say "New Employee" than the text will be showed up in the body of message
Dear IT,

Please be kind to create the following email address:
Name :
Position :
Company :
Phone Number :
Location :

Thanks
So with the script you mentioned before, my script will become like this:
Core.Customer.InitFocus();
switch ($('#Dest').val() ) { //this is where the queue is relevant (Dest = Queue)
case "5\|\|New Employee": // need to slash escape the pipes
document.compose.RichText.value = "Dear IT,<br/><br/>Please be kind to create the following email address:<br/>Name :<br/>Position :<br/>Company :<br/>Phone Number :<br/>Location :<br/><br/>Thanks<br/>"; // only if you want to change the body. destroys user input if queue changes
break;
default:
document.compose.RichText.value ="";
}
And it working so far... do you have other method for this kind of requirment? thanks for your advise..
Nelson.

jamlydm
OTRS newbie
Posts: 14
Joined: 24 Mar 2011, 23:03
OTRS Version?: 3.0.6

Re: How To show freetext for specific Queues for Customers

Post by jamlydm » 25 Mar 2011, 04:59

Wao.... Do you another example to learn. Becuase depend of the queue i want the user fill two o more fields and this fields need to be save in the database. Its this possible?

Help me or give a sight how to do it.

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 26 Mar 2011, 15:54

jamlydm wrote:i want the user fill two o more fields and this fields need to be save in the database. Its this possible?
Yes. Make sure the FreeTextFields exist via SysConfig, including Ticket::Frontend::CustomerTicketMessage###TicketFreeText, and add the appropriate lines to the code.


NOTE: This is part of the example. It's not everything.

Code: Select all

    case  "3\|\|Junk": // need to slash escape the pipes
      document.compose.RichText.value = "This is junk<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      document.getElementById('TicketFreeText1').style.display = 'block';
      document.getElementById('LabelTicketFreeText1').style.display = 'block';
   break;
   case "5\|\|AnotherQueue":
      document.compose.RichText.value = "This is another queue<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      document.getElementById('TicketFreeText2').style.display = 'block';
      document.getElementById('LabelTicketFreeText2').style.display = 'block';
      document.getElementById('TicketFreeText3').style.display = 'block';
      document.getElementById('LabelTicketFreeText3').style.display = 'block';
      document.getElementById('TicketFreeText4').style.display = 'block';
      document.getElementById('LabelTicketFreeText4').style.display = 'block';
  break;
 
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 29 Mar 2011, 15:03

By the way, I probably should have added that if you're going to do a LOT of different queues, you'll probably want to add a function that sets style.display = 'none' for all your TicketFreeText before you show things.

Code: Select all

<script type="text/javascript">
    Core.Customer.InitFocus();
//above two lines are already there
function nonetext() {
// you should only add lines in here that A) you have defined in SysConfig and B) that you will show ... somewhen (in the switch/case) but not all the time.
      document.getElementById('TicketFreeText1').style.display = 'none';
      document.getElementById('LabelTicketFreeText1').style.display = 'none';
      document.getElementById('TicketFreeText2').style.display = 'none';
      document.getElementById('LabelTicketFreeText2').style.display = 'none';
      document.getElementById('TicketFreeText3').style.display = 'none';
      document.getElementById('LabelTicketFreeText3').style.display = 'none';
      document.getElementById('TicketFreeText4').style.display = 'none';
      document.getElementById('LabelTicketFreeText4').style.display = 'none';
}
    switch ($('#Dest').val() ) { //this is where the queue is relevant (Dest = Queue)
    case  "3\|\|Junk": // need to slash escape the pipes
      document.compose.RichText.value = "This is junk<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      nonetext(); // This clears all the ticketfreetext listed before showing what you want
      document.getElementById('TicketFreeText1').style.display = 'block';
      document.getElementById('LabelTicketFreeText1').style.display = 'block';
    break;
   case "5\|\|AnotherQueue": //Don't forget to slash escape BOTH pipes.
      document.compose.RichText.value = "This is another queue<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      nonetext(); // This clears all the ticketfreetext listed before showing what you want
      document.getElementById('TicketFreeText2').style.display = 'block';
      document.getElementById('LabelTicketFreeText2').style.display = 'block';
      document.getElementById('TicketFreeText3').style.display = 'block';
      document.getElementById('LabelTicketFreeText3').style.display = 'block';
      document.getElementById('TicketFreeText4').style.display = 'block';
      document.getElementById('LabelTicketFreeText4').style.display = 'block';
   break;
    default:
      document.compose.RichText.value = $('#Dest').val(); //remove this. debug only. shows queue information
      document.getElementById('TicketFreeText1').style.display = 'none';
      document.getElementById('LabelTicketFreeText1').style.display = 'none';

 
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

jamlydm
OTRS newbie
Posts: 14
Joined: 24 Mar 2011, 23:03
OTRS Version?: 3.0.6

Re: How To show freetext for specific Queues for Customers

Post by jamlydm » 31 Mar 2011, 07:12

I have values for "TicketFreeText1", "TicketFreeText2" and "TicketFreeText3". I need to populate this 3 combobox with some values that i have in my database versión personal express Oracle. How can i connect to my own database to popule this field in my CustomerTicketMessage.dtl?

Woud it be better to create a table in Otrs and every 30 minutes export my datas from oracle express to otrs database?

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 01 Apr 2011, 14:15

I don't know if it would be "better" (populate an xml), but at a certain point, you'll either want to extend/overload the ticketfreetext to pull the data or use, forinstance, php or server side includes in your own form.

http://forums.otrs.org/viewtopic.php?f= ... t=0#p25901
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

Giulio Soleni
OTRS superhero
Posts: 389
Joined: 30 Dec 2010, 14:35
OTRS Version?: 5.0.x and 4.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 23 May 2011, 15:25

Hi crythias,
That indeed is a great hint since it goes in the direction of the "Template Ticket" I'm looking forward!
Thank you :)

I only would like to notice one thing that took me some hours to understand...
In the "case" list the order is absolutely important. That is:

something like this may work... (once defined the queues and the freetext fields...):

Code: Select all

switch ($('#Dest').val() ) { 
    case  "11\|\|Queue Eleven": 
      document.compose.RichText.value = "This is Queue Eleven<br/>and line 2";
      document.getElementById('TicketFreeText1').style.display = 'block';
      document.getElementById('LabelTicketFreeText1').style.display = 'block';
    break;
    case  "12\|\|Queue Twelve": 
      document.compose.RichText.value = "This is Queue Twelve<br/>and line 2";
      document.getElementById('TicketFreeText1').style.display = 'block';
      document.getElementById('LabelTicketFreeText1').style.display = 'block';
    break;
    default:
      document.compose.RichText.value = $('#Dest').val();
}
something like this cannot work:

Code: Select all

    switch ($('#Dest').val() ) { 
// THE NEXT CODE CANNOT WORK SINCE CASE SWITCHES ARE NOT IN LEXICOGRAPHICAL ORDER
    case  "12\|\|Queue Twelve": 
      document.compose.RichText.value = "This is Queue Twelve<br/>and line 2";
      document.getElementById('TicketFreeText1').style.display = 'block';
      document.getElementById('LabelTicketFreeText1').style.display = 'block';
    break;
    case  "11\|\|Queue Eleven": 
      document.compose.RichText.value = "This is Queue Eleven<br/>and line 2";
      document.getElementById('TicketFreeText1').style.display = 'block';
      document.getElementById('LabelTicketFreeText1').style.display = 'block';
    break;
    default:
      document.compose.RichText.value = $('#Dest').val();
}
Then a question...
Do you know if there's a way to reset the selection of the freetext fields to their defaults if you change the queue?
Taking my example...(the one that works :) ) I noticed that if you select "Queue Eleven" with, let's say "ValueX" for the freetext field and then I switch to "Queue Twelve", the prefilled value for the freetext remains "ValueX".

Giulio
OTRS 5.0.x on CentOS 6.9 with MySQL 5.6 database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.

Giulio Soleni
OTRS superhero
Posts: 389
Joined: 30 Dec 2010, 14:35
OTRS Version?: 5.0.x and 4.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 23 May 2011, 16:34

Hi crythias,
I was looking for such a customization of New Ticket in the Customer console and your hint really addresses my needs :)
Thank you!

I only would like to notice a little thing that took me some hours of testing before I discover...
In the "case" switches, lexicographical order is essential!
That is I cannot for example set the sequence:

case "8\|\|MyTestQueue":
[...]
case "6\|\|AnotherTestQueue":

since it does not work. You have to put the selection in the correct order:

case "6\|\|AnotherTestQueue":
[...]
case "8\|\|MyTestQueue":

I noticed also that once you have selected a value for a freetext field, that value remains even if I change idea and I select another queue (for which I made available the same freetext of course).
Do you know a way to reset this selection?

Thank you
Giulio
OTRS 5.0.x on CentOS 6.9 with MySQL 5.6 database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 23 May 2011, 17:07

Giulio Soleni wrote:Do you know if there's a way to reset the selection of the freetext fields to their defaults if you change the queue?
No, but you can assign the .value to the freetextfield.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

Rmack09
OTRS newbie
Posts: 42
Joined: 28 Jan 2011, 15:37
OTRS Version?: 3_1_3
Real Name: Mack

Re: How To show freetext for specific Queues for Customers

Post by Rmack09 » 06 Jun 2011, 21:05

Can this work for Ticket Type as well? If so how would I do it?
OTRS Ver. 3.1.3 on Ubuntu 10.04 with MySQL database 5.1.49

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 18 Jun 2011, 06:27

OK, so I enabled it here: Edit Config Settings in Ticket -> Core::Ticket


So, that (my?) code at the bottom? before the end of the script, you can do something like this:

Code: Select all

    switch ($('#TypeID').val() ) {
    case "1":
        document.getElementById('Dest').value = '3\|\|Junk';
    break;
    default:
    }
 
Understand that your logic has to have some boundaries of "does it make sense to do this?" Because a Queue that changes a Type that changes a Queue... Or something else, like: Why does the Queue always change back to Junk? Why can't I change that separately?

What if you wanted to change the Queue list by changing the Type? ... whew. You have to ask some hard questions, don't you? http://www.javascriptkit.com/javatutors ... tent.shtml

The best (?) option is to do some array storage of the list, clear the list, and add the entries you want to show. Don't forget that if you are using Dest (Queues), you must slash escape the pipes when referencing them.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

Rmack09
OTRS newbie
Posts: 42
Joined: 28 Jan 2011, 15:37
OTRS Version?: 3_1_3
Real Name: Mack

Re: How To show freetext for specific Queues for Customers

Post by Rmack09 » 18 Jul 2011, 14:08

Sorry it took so long to respond but I used the code and it works now! Thanks
OTRS Ver. 3.1.3 on Ubuntu 10.04 with MySQL database 5.1.49

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 18 Aug 2011, 22:09

For people interested in how this should work with, for instance AgentTicketPhone, place your script after the FormUpdate

Code: Select all

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

 
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 29 Sep 2011, 15:03

Please ask your questions in the Help forums. This post is getting unwieldy and the posts here have to be approved to show.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

StefanoBoccanera
OTRS expert
Posts: 76
Joined: 23 Feb 2011, 15:43
OTRS Version?: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: How To show freetext for specific Queues for Customers

Post by StefanoBoccanera » 18 Oct 2011, 18:26

crythias wrote:By the way, I probably should have added that if you're going to do a LOT of different queues, you'll probably want to add a function that sets style.display = 'none' for all your TicketFreeText before you show things.

Code: Select all


<script type="text/javascript">
    Core.Customer.InitFocus();
//above two lines are already there
function nonetext() {
// you should only add lines in here that A) you have defined in SysConfig and B) that you will show ... somewhen (in the switch/case) but not all the time.
      document.getElementById('TicketFreeText1').style.display = 'none';
      document.getElementById('LabelTicketFreeText1').style.display = 'none';
      document.getElementById('TicketFreeText2').style.display = 'none';
      document.getElementById('LabelTicketFreeText2').style.display = 'none';
      document.getElementById('TicketFreeText3').style.display = 'none';
      document.getElementById('LabelTicketFreeText3').style.display = 'none';
      document.getElementById('TicketFreeText4').style.display = 'none';
      document.getElementById('LabelTicketFreeText4').style.display = 'none';
}
    switch ($('#Dest').val() ) { //this is where the queue is relevant (Dest = Queue)
    case  "3\|\|Junk": // need to slash escape the pipes
      document.compose.RichText.value = "This is junk<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      nonetext(); // This clears all the ticketfreetext listed before showing what you want
      document.getElementById('TicketFreeText1').style.display = 'block';
      document.getElementById('LabelTicketFreeText1').style.display = 'block';
    break;
   case "5\|\|AnotherQueue": //Don't forget to slash escape BOTH pipes.
      document.compose.RichText.value = "This is another queue<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      nonetext(); // This clears all the ticketfreetext listed before showing what you want
      document.getElementById('TicketFreeText2').style.display = 'block';
      document.getElementById('LabelTicketFreeText2').style.display = 'block';
      document.getElementById('TicketFreeText3').style.display = 'block';
      document.getElementById('LabelTicketFreeText3').style.display = 'block';
      document.getElementById('TicketFreeText4').style.display = 'block';
      document.getElementById('LabelTicketFreeText4').style.display = 'block';
   break;
    default:
      document.compose.RichText.value = $('#Dest').val(); //remove this. debug only. shows queue information
      document.getElementById('TicketFreeText1').style.display = 'none';
      document.getElementById('LabelTicketFreeText1').style.display = 'none';

Hi crythias

I am trying to use your example to get Freetext values according to the Ticket Type, but we have an error about a Null FreeText1 value, and nothing is shown.

Now I'm wondering if the example it's only to show free text values already set.

In that case how we get alternative free text value switching on Ticket Type ?

best regards

stefano

p.s.

The switch/case structure is correct I already use the same approach to set the destination queue based on Ticket Type.
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 19 Oct 2011, 14:33

If the field is required, you'll have a problem with my code.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

StefanoBoccanera
OTRS expert
Posts: 76
Joined: 23 Feb 2011, 15:43
OTRS Version?: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: How To show freetext for specific Queues for Customers

Post by StefanoBoccanera » 27 Oct 2011, 10:01

Hi crythias

I'm trying to solve the problem having 'mandatory' freetext. :(


Have you some suggestion about it?
regards

stefano
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 27 Oct 2011, 20:42

Your options are to populate the field or use CSS to make the field mandatory only when it shows.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

StefanoBoccanera
OTRS expert
Posts: 76
Joined: 23 Feb 2011, 15:43
OTRS Version?: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: How To show freetext for specific Queues for Customers

Post by StefanoBoccanera » 28 Oct 2011, 09:58

crythias wrote:Your options are to populate the field or use CSS to make the field mandatory only when it shows.
Thanks crythias.
I 'll follow your suggestion.

regards

stefano
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres

StefanoBoccanera
OTRS expert
Posts: 76
Joined: 23 Feb 2011, 15:43
OTRS Version?: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: How To show freetext for specific Queues for Customers

Post by StefanoBoccanera » 28 Oct 2011, 12:25

crythias wrote:Your options are to populate the field or use CSS to make the field mandatory only when it shows.
Hi crythias

I have some doubt about the two options:

- Populate the field: I'd like avoid this option, my goal is force the customer to put a value into the field, if I populate in advance the field, probably
the customer would not attention to the content and I would not have the 'mandatory' control as safe choice.

- CSS . I'm note expert into CSS so I have some additional question about it:

- I didn't find any css file into skin directory related to Ticket management, so I think you are referring to write down some piece of CSS code.
- I understand your suggestion like: define freetext not mandatory, then modify within the dtl file the code using CSS istruction to meke mandatory fereetext you want.
Is it correct? and in this case would you suggest what instruction use ?

best regards

stefano
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres

Giulio Soleni
OTRS superhero
Posts: 389
Joined: 30 Dec 2010, 14:35
OTRS Version?: 5.0.x and 4.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 04 Jan 2012, 01:51

Hi,
I found this howto very useful ... until we all come to the 3.1 beta releases which substitute the freetext fields with the dynamic fields.
I am trying the 3.1-beta3 these days and - as expected - the /CustomerTicketMessage.dtl template with these adjustments, used until now, cannot be used anymore :(

I am not so friendly with javascript and all ... may you please help me updating this template and show me how to use the dynamic fields for specific queues, instead of the old and now deprecated freetext fields?

For my purposes... I have only one dropdown dynamic field that I would like to show for 1 queue only in the CustomerTicketMessage, while I would like to hide it for any other queue the customers may select when they create a new ticket.

This is the code I used until now and I need to adapt...

Code: Select all

function nonetext() {
	document.compose.Subject.value = "";
	document.compose.RichText.value = "";
	document.getElementById('TicketFreeText1').style.display = 'none';
	document.getElementById('LabelTicketFreeText1').style.display = 'none';
}

switch ($('#Dest').val() ) { 
    case  "9\|\|Queue_Y": // need to slash escape the pipes
		nonetext();
		document.getElementById('TicketFreeText1').style.display = 'block';
		document.getElementById('LabelTicketFreeText1').style.display = 'block';
		document.getElementById('LabelTicketFreeText1').className = 'Mandatory';
		document.getElementById('TicketFreeText1').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';
	break;
	
    default:
      nonetext();
}

Thankyou very much in advance!

Giulio
OTRS 5.0.x on CentOS 6.9 with MySQL 5.6 database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.

Giulio Soleni
OTRS superhero
Posts: 389
Joined: 30 Dec 2010, 14:35
OTRS Version?: 5.0.x and 4.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 17 Jan 2012, 12:02

Ok... solved :)
digging around in the code and checking the actual configurations of the new dynamic field feature I found out that the old Free Text Fields that you may have set for the 3.0.x version are all imported and converted as dynamic fields in the new OTRS version.
Specifically, each old free text field is inherited with the new specifics:
the id for label which was LabelTicketFreeTextnn becomes LabelDynamicField_TicketFreeTextnn
the id for the object itself, which was TicketFreeTextnn becomes DynamicField_TicketFreeTextnn

I have not tested it, but I am quite sure that if you define a new dynamic field named "myNewDynField" you will have:
id for label: LabelDynamicField_myNewDynField
id for the object itself: DynamicField_myNewDynField

So for me the code that works is the following:

Code: Select all

function nonetext() {
   document.compose.Subject.value = "";
   document.compose.RichText.value = "";
   document.getElementById('DynamicField_TicketFreeText1').style.display = 'none';
   document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'none';
}

switch ($('#Dest').val() ) { 
    case  "9\|\|Queue_Y": // need to slash escape the pipes
      nonetext();
      document.getElementById('DynamicField_TicketFreeText1').style.display = 'block';
      document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'block';
      document.getElementById('LabelDynamicField_TicketFreeText1').className = 'Mandatory';
      document.getElementById('DynamicField_TicketFreeText1').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';
   break;
   
    default:
      nonetext();
}
OTRS 5.0.x on CentOS 6.9 with MySQL 5.6 database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.

NickGnd
OTRS newbie
Posts: 17
Joined: 16 Jan 2012, 20:37
OTRS Version?: 3.0.11
Real Name: Nicolò
Location: Ferrara (Italy)

Re: How To show freetext for specific Queues for Customers

Post by NickGnd » 23 Feb 2012, 10:58

Great job Giulio, it work fine. :D
But if I want the dynamic field not mandatory? Which name class?

Code: Select all

 document.getElementById('LabelDynamicField_TicketFreeText1').className = ' XXX ? '; 
Thanks a lot!

Nicolò

Giulio Soleni
OTRS superhero
Posts: 389
Joined: 30 Dec 2010, 14:35
OTRS Version?: 5.0.x and 4.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 04 Mar 2012, 18:39

Ciao Nicolò!

thank you for your comment... I noticed that my code on that specific point was a little bit confusing.
Anyhow it should not be matter of "className = 'Mandatory'" attribute but instead of "Validate_Required" attribute, and that 'Validate_Required' should be set (or not set, if you would like the dyn field to be left optional) for 'DynamicField_TicketFreeText1' and NOT for 'LabelDynamicField_TicketFreeText1'.
In other words ... I checked that the code to set a mandatory dyn field is the following:

Code: Select all

    case  "9\|\|Queue_Y": // need to slash escape the pipes
      nonetext();
      document.getElementById('DynamicField_TicketFreeText1').style.display = 'block';
      document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'block';
      document.getElementById('DynamicField_TicketFreeText1').className = 'Validate_Required';
   break;
while the code to set the same filed optional should be the same without the 'Validate_Required' attribute:

Code: Select all

    case  "9\|\|Queue_Y": // need to slash escape the pipes
      nonetext();
      document.getElementById('DynamicField_TicketFreeText1').style.display = 'block';
      document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'block';
   break;
What you DO NOT have to do in either way is to set this dyn field required in the SysConfig Ticket::Frontend::CustomerTicketMessage###DynamicField where the dyn field should be set simply Enabled (1) and not Enabled and Required (2) or else you won't be able to create any other new ticket for the other queues where the dyn field is not shown, since it would be always required, for the ticket opened on those other queues also.

I am right now looking for a way to include a tip message in case of validation required, something that say "this field is required!" if you forgot to fill it with a value, (as it is already set for other mandatory fields like subject and body) ...

I admit I am not so friendly in editing these templates and I would really be grateful to anyone that could shed some further light in the usage of these parameters.
OTRS 5.0.x on CentOS 6.9 with MySQL 5.6 database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.

nickyls
OTRS expert
Posts: 87
Joined: 10 Mar 2012, 07:57
OTRS Version?: OTRS3

Re: How To show freetext for specific Queues for Customers

Post by nickyls » 15 Mar 2012, 20:20

hi experts!
we are using otrs 3.1.2 In this advance version i have two dropdown dynamic fields.what i want is depend on first dynamic field value, second dynamic value should change.in earlier version of otrs it can be configured by freetextkey & freetextvalue.will u share a script so that i can configure what i required?
OTRS 3.1.X

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 23 Mar 2012, 22:27

It looks like DynamicField_TicketFreeText1 is an example of one field.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

kiki
OTRS newbie
Posts: 6
Joined: 05 May 2012, 23:34
OTRS Version?: 3.1.1

Re: How To show freetext for specific Queues for Customers

Post by kiki » 06 May 2012, 22:23

Hi Giulio, i have a doubt; this code also works for version 3.1.1? because I tried it in my version, but does not work. I'm doing something wrong? or should I do more? thanks in advance.

kiki
OTRS newbie
Posts: 6
Joined: 05 May 2012, 23:34
OTRS Version?: 3.1.1

Re: How To show freetext for specific Queues for Customers

Post by kiki » 07 May 2012, 11:19

Hello everyone, I resolved, I have added code to the end of the session <script type="text/javascript"> at the bottom of everything I found in this session. :D

kp20mar
OTRS newbie
Posts: 28
Joined: 12 Dec 2011, 09:38
OTRS Version?: 3.0.10

Re: How To show freetext for specific Queues for Customers

Post by kp20mar » 11 Jun 2012, 06:08

Hi everyone,
how can i change color, font, size of freetext? and i want the customer can't change the freetext, they must fill the form freetext that I created.

Dominik1986
OTRS newbie
Posts: 5
Joined: 09 Jul 2012, 10:43
OTRS Version?: 3.0.0
Real Name: Dominik Schmucker

Re: How To show freetext for specific Queues for Customers

Post by Dominik1986 » 09 Jul 2012, 10:51

I am trying to to something like that in AgentTicketFreeText. So I make the JavaScript changes in AgentTicketActionCommon, because it is included by AgentTicketFreeText. Here's what I have so far, the queue is called "30 CMT", when the Ticket is in this queue TicketFreeText2 shouldn't be visible.

Code: Select all

<script type="text/javascript">
    Core.Agent.TicketAction.Init();
    switch ($('#Dest').val() ) {
	    case  "30 CMT":
	      document.getElementById('TicketFreeText2').style.display = 'none';
	      document.getElementById('LabelTicketFreeText2').style.display = 'none';
	    break;
	    default:
	      document.getElementById('TicketFreeText2').style.display = 'block';
	      document.getElementById('LabelTicketFreeText2').style.display = 'block';
    }
</script>

ccummings
OTRS newbie
Posts: 35
Joined: 16 Aug 2012, 18:55
OTRS Version?: 3.1.8
Real Name: Craig
Company: IIT

Re: How To show freetext for specific Queues for Customers

Post by ccummings » 13 Sep 2012, 20:57

crythias wrote:If the field is required, you'll have a problem with my code.
crythias wrote:Your options are to populate the field or use CSS to make the field mandatory only when it shows.
What needs to be done in order to hide a required field? I have tried setting aria-required and aria-invalid = false and removing Mandatory and Validate_Required from the class attributes, but I still get an error stating this field is required. I would prefer not to populate it with a dummy value if it can be avoided.

Code: Select all

    Core.Agent.TicketAction.Init();
    switch ($('#Dest').val() ) { //this is where the queue is relevant (Dest = Queue)
    case  "2\|\|Default": // need to slash escape the pipes
      document.compose.RichText.value = "This is default<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      document.getElementById('LabelDynamicField_TicketCategory').style.display = 'block';
      document.getElementById('DynamicField_TicketCategory').style.display = 'block';
    break;
    case  "\|\|-": // need to slash escape the pipes
      document.compose.RichText.value = "This is default<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      document.getElementById('LabelDynamicField_TicketCategory').style.display = 'block';
      document.getElementById('DynamicField_TicketCategory').style.display = 'block';
    break;
    default:
      document.compose.RichText.value = $('#Dest').val(); //remove this. debug only. shows queue information
      document.getElementById('LabelDynamicField_TicketCategory').style.display = 'none';
      document.getElementById('LabelDynamicField_TicketCategory').setAttribute('class', '');
      document.getElementById('DynamicField_TicketCategory').style.display = 'none';
      document.getElementById('DynamicField_TicketCategory').setAttribute('aria-required', 'false');
      document.getElementById('DynamicField_TicketCategory').setAttribute('aria-invalid', 'false');
      document.getElementById('DynamicField_TicketCategory').setAttribute('class', 'DynamicField_TicketCategory');
      
    }

Giulio Soleni
OTRS superhero
Posts: 389
Joined: 30 Dec 2010, 14:35
OTRS Version?: 5.0.x and 4.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 13 Sep 2012, 21:04

I noticed that as soon as a user wants to add an attachment, or wants to select another queue, or for whatever reason the form should be reloaded... all the content of the form is reset to the template condition (losing all the text already filled up...).
I have adapted the code with a "confirm" popup that allows the user to reset the form to the original template condition or to keep the text already filled-up. This popup appears every time a reload is necessary while the form is being compiled.

Here's the new code tested with 2 queues as example and 1 dyn-field "test01" allowed (and required) for 1 queue only:

Please note that I renamed and changed the nonetext() function into initText() ... that function takes care to "count" all the modifications made to subject and/or body of the new ticket form.

Code: Select all

//// START EDIT TEMPLATE
function initText() {
	var thisSubject = $('#Subject').val();
	var thisRichText = $('#RichText').val();
	var sbjLen = thisSubject.length;
	var textLen = thisRichText.length;
	var totLen = sbjLen*1 + textLen*1;
	document.compose.Subject.value = $('#Subject').val();
	document.compose.RichText.value = $('#RichText').val();
//// DYNAMIC FIELD test01 SHOULD HAVE BEEN ALREADY DEFINED VIA GUI INTERFACE AND HERE IT IS *DISABLED* BY DEFAULT:
	document.getElementById('DynamicField_test01').style.display = 'none';
	document.getElementById('LabelDynamicField_test01').style.display = 'none';
return totLen;
}
switch ($('#Dest').val() ) {
//
//// IMPORTANT: QueueID SORTING ORDER MUST BE RESPECTED 
//
case "\|\|-":
	var totLen = initText();
//// DYNAMIC FIELD test01 HAS ALREADY BEEN DEFINED VIA GUI INTERFACE AND HERE IT IS *KEPT RESET AND HIDDEN* IN THE STARTING QUEUE SELECTION CONDITION '-':
	document.compose.DynamicField_test01.value = "";
	if (totLen > 0)
	{
		var r=confirm("Click Ok to keep the subject and text of the ticket as they are.\nClick Cancel to reset the ticket form to the original template.");
		if (r==false)
		{
			document.compose.Subject.value = "";
			document.compose.RichText.value = "";
		}
	}
	break;

// START TEMPLATE FOR Service Y Support QUEUE
case "8\|\|Service Y Support": // DOUBLE-CHECK QUEUE-ID!!
	var totLen = initText();
//// DYNAMIC FIELD test01 HAS ALREADY BEEN DEFINED VIA GUI INTERFACE AND HERE IT IS *ACTIVATED SHOWN AND MANDATORY* FOR THIS QUEUE:
	document.getElementById('DynamicField_test01').style.display = 'block';
	document.getElementById('LabelDynamicField_test01').style.display = 'block';
	document.getElementById('DynamicField_test01').className = 'Validate_Required'; // comment this line to let the dynfield optional
	var thisSubject = "Request Template for Service Y Support";
	var thisText = "... a simple template for  <B>Service Y Support</B> request&nbsp<br/><B>Problem description:</B>&nbsp...<br/><br/>";
	if (totLen == 0) // text and subject are empty
	{
		document.compose.Subject.value = thisSubject;
		document.compose.RichText.value = thisText;
	}
	else // text and/or subject have been changed
	{
		var r=confirm("Click Ok to keep the subject and text of the ticket as they are.\nClick Cancel to reset the ticket form to the original template.");
		if (r==false)
		{
			document.compose.Subject.value = thisSubject;
			document.compose.RichText.value = thisText;
		}
	}
	break;
//END TEMPLATE FOR Service Y Support QUEUE

// START TEMPLATE FOR Service Z Support::Application A QUEUE
case "10\|\|Service Z Support::Application A": // DOUBLE-CHECK QUEUE-ID!!
	var totLen = initText();
	var thisSubject = "... a simple template for  <B>Application A on Service Z Support</B> request&nbsp<br/><B>Problem description:</B>&nbsp...<br/><br/>";
//// DYNAMIC FIELD test01 HAS ALREADY BEEN DEFINED VIA GUI INTERFACE AND HERE IT IS *KEPT RESET AND HIDDEN* FOR THIS QUEUE:
	document.compose.DynamicField_test01.value = "";
	if (totLen == 0) // text and subject are empty
	{
		document.compose.Subject.value = thisSubject;
		document.compose.RichText.value = thisText;
	}
	else // text and/or subject have been changed
	{
		var r=confirm("Click Ok to keep the subject and text of the ticket as they are.\nClick Cancel to reset the ticket form to the original template.");
		if (r==false)
		{
			document.compose.Subject.value = thisSubject;
			document.compose.RichText.value = thisText;
		}
	}
	break;
//END TEMPLATE FOR Service Z Support::Application A QUEUE

default:
	var totLen = initText();
//// DYNAMIC FIELD test01 HAS ALREADY BEEN DEFINED VIA GUI INTERFACE AND HERE IT IS *KEPT RESET AND HIDDEN* BY DEFAULT:
	document.compose.DynamicField_test01.value = "";
	if (totLen > 0)
	{
		var r=confirm("Click Ok to keep the subject and text of the ticket as they are.\nClick Cancel to reset the ticket form.");
		if (r==false)
		{
			document.compose.Subject.value = "";
			document.compose.RichText.value = "";
		}
	}
}
//// END EDIT TEMPLATE
OTRS 5.0.x on CentOS 6.9 with MySQL 5.6 database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.

Giulio Soleni
OTRS superhero
Posts: 389
Joined: 30 Dec 2010, 14:35
OTRS Version?: 5.0.x and 4.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 14 Sep 2012, 00:32

ccummings wrote: What needs to be done in order to hide a required field?
As I and crythias already told, I think that the only problem could arise if you set your dyn fields required in the SysConfig Ticket::Frontend::CustomerTicketMessage###DynamicField
That is, in other words, the dyn fields should only be set as "allowed" with content flag set to '1 and NOT set mandatory with content flag set to '2'.

HTH
Giulio
OTRS 5.0.x on CentOS 6.9 with MySQL 5.6 database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.

ccummings
OTRS newbie
Posts: 35
Joined: 16 Aug 2012, 18:55
OTRS Version?: 3.1.8
Real Name: Craig
Company: IIT

Re: How To show freetext for specific Queues for Customers

Post by ccummings » 14 Sep 2012, 17:09

Giulio Soleni wrote:
ccummings wrote: What needs to be done in order to hide a required field?
As I and crythias already told, I think that the only problem could arise if you set your dyn fields required in the SysConfig Ticket::Frontend::CustomerTicketMessage###DynamicField
That is, in other words, the dyn fields should only be set as "allowed" with content flag set to '1 and NOT set mandatory with content flag set to '2'.

HTH
Giulio
...but then it won't be required when it IS visible either. In effect, you're saying that you can't hide a required field without making it NOT required...or as crythias suggested, populating it with some value. I just went ahead and populated it with a dummy value.

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 14 Sep 2012, 20:44

ccummings wrote:but then it won't be required when it IS visible either
example:

Code: Select all

      document.getElementById('LabelTicketFreeText1').className = 'Mandatory';
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

teetones
OTRS newbie
Posts: 9
Joined: 15 Nov 2011, 15:38
OTRS Version?: 3.11
Real Name: tee tones

Re: How To show freetext for specific Queues for Customers

Post by teetones » 18 Sep 2012, 17:31

Hello Crythias

I want to display freetext field only for certain queue.Could you please to explain the step by step what value should i put on the script for OTRS version 3.1.9? The FreeText field in the post (Ticket::Frontend::CustomerTicketMessage###TicketFreeText) no longer exits

Thanks

tee

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 18 Sep 2012, 21:21

@teetones (and anyone else who is looking for this to be adapted to Dynamic Fields)
Please ready Giulio Soleni's posts.
You MUST enable the field in SysConfig for your specific interface for it to be displayed at all.

This code hides the label and the field for DynamicField "test01"

Code: Select all

   document.getElementById('DynamicField_test01').style.display = 'none';
   document.getElementById('LabelDynamicField_test01').style.display = 'none';
change 'none' to 'block and it displays.

This code removes the Mandatory attribute

Code: Select all

      document.getElementById('LabelDynamicField_test01').setAttribute('class', '');
Read Giulio's posts for more complete examples.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

bayerex
OTRS wizard
Posts: 164
Joined: 03 Dec 2012, 00:30
OTRS Version?: 3.2.7

Re: How To show freetext for specific Queues for Customers

Post by bayerex » 18 Dec 2012, 17:56

How do I change the font colour? e.g to red

I can get it to enter the text but the colour is not changing.

Code: Select all

var vari = $('#Dest').val();

if(vari=='16||daVinci') {
  document.getElementById('RichText').style.color = "#999";
  document.getElementById('RichText').value = "Bitte senden Sie Ihre Plandatei mit, wenn es sich um Dateibezogene Probleme handelt!";
} 
Current Production Server (recently switched from Windows)
OTRS 3.2.7 on Ubuntu 12.04LTS 64bit
PHP 5.3.10-1ubuntu3.6
mysql Ver 14.14 Distrib 5.5.31

Previous Production Server:
Windows 2008
MySQL 5.1.51 Community Server
Strawberry Perl 5.12.3.0

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 19 Dec 2012, 18:20

as a hint,

Code: Select all

      document.compose.RichText.value = "This is default<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
... ? no? :) ok. <br /> is HTML markup

Still don't get it? :)

Code: Select all

<span style="color:red">This is red text</span><br />and line 2 is not red
(I can't guarantee that the RichText filter will keep the color upon submit, nor that this will work at all, but if I were going to do it...)

but you can use the .style.color for fields and labels.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

User avatar
baron
OTRS newbie
Posts: 4
Joined: 06 Sep 2008, 21:27
OTRS Version?: CVS

Re: How To show freetext for specific Queues for Customers

Post by baron » 18 Jan 2013, 18:26

Dear all,

OTRS AG provides a nice Feature Add On for this task:

http://www.otrs.com/en/software/otrs-he ... ms/#c39705

Cheers, Nils
Produktiv: OTRS 2.4.x, OTRS::ITSM 1.3.x
Testing: OTRS CVS
System: Debian 5.0, Mac OS X 10.6
Webserver: Apache2
Database: MySQL 5

Niemals die Defaults.pm ändern! :: as JoJo said :-)
Professioneller Support, Consulting und Entwicklung: http://www.otrs.com/de :: Bei weiteren Fragen: enjoy@otrs.com hilft gerne

katerina
OTRS newbie
Posts: 46
Joined: 19 Jul 2012, 13:01
OTRS Version?: 3.1.7
Real Name: Katerina
Company: PNB

Re: How To show freetext for specific Queues for Customers

Post by katerina » 21 Jan 2013, 12:09

I was happy to read:
crythias wrote:For people interested in how this should work with, for instance AgentTicketPhone, place your script after the FormUpdate

Code: Select all

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

 
Thank for your help, but this code doesn't work for me.
It worked for me in the CustomerTicketMessage.dtl, where I have

Code: Select all

function nonetext() {
       document.compose.Subject.value = "";
       document.compose.RichText.value = "";
       document.getElementById('DynamicField_jmenoPC').style.display = 'none';
       document.getElementById('LabelDynamicField_jmenoPC').style.display = 'none';
    }

    switch ($('#Dest').val() ) {
    //    case  "5\|\|Technicke": // need to slash escape the pipes
case  "3\|\|Junk":
          nonetext();
          document.getElementById('DynamicField_jmenoPC').style.display = 'block';
          document.getElementById('LabelDynamicField_jmenoPC').style.display = 'block';
         // document.getElementById('LabelDynamicField_jmenoPC').className = 'Mandatory';
          document.getElementById('DynamicField_jmenoPC').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';
       break;

        default:
          nonetext();
    }
but it doesn't work in the AgentTicketPhone.dtl, which I have in my version 3.1.12

Code: Select all

<script type="text/javascript">//<![CDATA[
    $('#NextStateID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'NextStateID', [ 'TypeID', 'Dest', 'NewUserID','NewResponsibleID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
//********************************************************************
function nonetext() {
       document.compose.Subject.value = "";
       document.compose.RichText.value = "";
       document.getElementById('DynamicField_jmenoPC').style.display = 'none';
       document.getElementById('LabelDynamicField_jmenoPC').style.display = 'none';
    }

    switch ($('#Dest').val() ) {
    //    case  "5\|\|Technicke": // need to slash escape the pipes
case  "3\|\|Junk": 
          nonetext();
          document.getElementById('DynamicField_jmenoPC').style.display = 'block';
          document.getElementById('LabelDynamicField_jmenoPC').style.display = 'block';
         // document.getElementById('LabelDynamicField_jmenoPC').className = 'Mandatory';
          document.getElementById('DynamicField_jmenoPC').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';
       break;
       
        default:
          nonetext();
    }

//*************************************************************************
});
//]]></script>
I don't know how to change the code to make it work, I tried to move it one and two lines up (above Core.AJAX) but it doesn't work.
I can see the Dynamic field named jmenoPC in all the queues, not only in the queue Technicke.
Can you help me please?
otrs v.5 on linux CentOS 6.8 with MySQL Ver 14.14 Distrib 5.1.73, openLDAP

teetones
OTRS newbie
Posts: 9
Joined: 15 Nov 2011, 15:38
OTRS Version?: 3.11
Real Name: tee tones

Re: How To show freetext for specific Queues for Customers

Post by teetones » 08 Feb 2013, 02:01

Hi

I am using the code below to try to show different text on different queues and it is not working when i change queues. Can someone help me please? Thanks. Am using ver 3.2.1

Code: Select all

 document.getElementById('Subject').style.display = 'none';
    document.getElementById('RichText').style.display = 'none';
    switch ($('#Dest').val() ) {  //(Dest = Queue)
case "1\|\|q1":
       document.getElementById('Subject').style.display = 'block';
       document.getElementById('RichText').style.display = 'block';
       document.compose.Subject.value = "[PRE] Form Raised for {employee name}";
       document.compose.RichText.value = "Employee Name: \nPosition: ";
    break;
case "2\|\|q2":
       document.getElementById('Subject').style.display = 'block';
       document.getElementById('RichText').style.display = 'block';
       document.compose.Subject.value = "[POST] Form Raised for [employee name]";
       document.compose.RichText.value = "Employee Name: \nLeaving Date: ";
    break;
case "3\|\|q3":
       document.getElementById('Subject').style.display = 'block';
       document.getElementById('RichText').style.display = 'block';
       document.compose.Subject.value = "";
       document.compose.RichText.value = "";
    break;
default:
       document.compose.Subject.value = "";
       document.compose.RichText.value = "";
}
Last edited by crythias on 17 Feb 2014, 16:55, edited 1 time in total.
Reason: code tags

Giulio Soleni
OTRS superhero
Posts: 389
Joined: 30 Dec 2010, 14:35
OTRS Version?: 5.0.x and 4.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 17 Feb 2013, 11:16

teetones wrote:Hi
I am using the code below to try to show different text on different queues and it is not working when i change queues. Can someone help me please? Thanks. Am using ver 3.2.1
I did not check if the solution works on the 3.2.1 version yet, but you are using document.getElementById calls on Text and Subject ... that's not good.
Please double check the suggested code in the posts above and you'll see that document.getElementById is used only to make reference to Dynamic Fields.

HTH
Giulio
OTRS 5.0.x on CentOS 6.9 with MySQL 5.6 database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show DynamicFields for specific Queues for Custom

Post by crythias » 21 Mar 2013, 21:36

Version 3.2:
Should work like AgentTicketPhone:

Code: Select all

<script type="text/javascript">//<![CDATA[
function nonetext() {
   document.compose.Subject.value = "";
   document.compose.RichText.value = "";
   document.getElementById('DynamicField_TicketFreeText1').style.display = 'none';
   document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'none';
}
    $('#Dest').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewCustomerTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'PriorityID', 'ServiceID', 'SLAID', $Data{"DynamicFieldNamesStrg"}]);
switch ($('#Dest').val() ) { 
    case  "9\|\|Queue_Y": // need to slash escape the pipes
      nonetext();
      document.getElementById('DynamicField_TicketFreeText1').style.display = 'block';
      document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'block';
      document.getElementById('LabelDynamicField_TicketFreeText1').className = 'Mandatory';
      document.getElementById('DynamicField_TicketFreeText1').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';
   break;
   
    default:
      nonetext();
}
    });
//]]></script>
 
(see other hints above for different implementations. You may not want or need Mandatory, for instance.)
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

eterjack
OTRS expert
Posts: 55
Joined: 21 Sep 2012, 01:45
OTRS Version?: 3.1.10

Re: How To show freetext for specific Queues for Customers

Post by eterjack » 03 Apr 2013, 04:31

Good evening, it is possible to use in case a string instead of a number id, when we use the DynamicField based type?

Code: Select all

function nonetext() {
   document.compose.Subject.value = "";
   document.compose.RichText.value = "";
   document.getElementById('DynamicField_email').style.display = 'none';
   document.getElementById('LabelDynamicField_email').style.display = 'none';
}
nonetext();
    $('#TypeID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'TypeID', ['Dest', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
			switch ($('#TypeID').val() ) { 
			case  "Request": // need to slash escape the pipes
			nonetext();
			
			document.getElementById('DynamicField_email').style.display = 'block';
			document.getElementById('LabelDynamicField_email').style.display = 'block';
			document.getElementById('LabelDynamicField_email').className = 'Mandatory';
			document.getElementById('DynamicField_email').className = 'Validate_Required';
		   break;
		   
			default:
			  nonetext();
		}
Last edited by crythias on 17 Feb 2014, 16:57, edited 1 time in total.
Reason: code tags

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias » 04 Apr 2013, 01:01

eterjack wrote:switch ($('#TypeID').val() ) {
case "Request":
If you're switching on TypeID (or any other field), you will need to "case" on the <option> "value" for the switch field.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

SantaPe
OTRS expert
Posts: 53
Joined: 13 Mar 2013, 18:02
OTRS Version?: 3.2.2

Re: How To show DynamicFields for specific Queues for Custom

Post by SantaPe » 11 Apr 2013, 10:22

crythias wrote:Version 3.2:
Should work like AgentTicketPhone:

Code: Select all

<script type="text/javascript">//<![CDATA[
function nonetext() {
   document.compose.Subject.value = "";
   document.compose.RichText.value = "";
   document.getElementById('DynamicField_TicketFreeText1').style.display = 'none';
   document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'none';
}
    $('#Dest').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewCustomerTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'PriorityID', 'ServiceID', 'SLAID', $Data{"DynamicFieldNamesStrg"}]);
switch ($('#Dest').val() ) { 
    case  "9\|\|Queue_Y": // need to slash escape the pipes
      nonetext();
      document.getElementById('DynamicField_TicketFreeText1').style.display = 'block';
      document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'block';
      document.getElementById('LabelDynamicField_TicketFreeText1').className = 'Mandatory';
      document.getElementById('DynamicField_TicketFreeText1').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';
   break;
   
    default:
      nonetext();
}
    });
//]]></script>
 
(see other hints above for different implementations. You may not want or need Mandatory, for instance.)
I want to use this code to show my dynamicField (a dropdownlist) only when a specific queue is chosen. This needs to be in the customer front-end.
So I need to edit 'CustomerTicketMessage.dtl' right?
I'm confused on where I need to add this code... On the bottom underneath

Code: Select all

 Core.Customer.InitFocus();
?

What other parameters do I have to change?
OTRS 3.2 - Windows Server 2008R2 - mysql

Post Reply