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: 9981
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 » 11 Apr 2013, 14:29

SantaPe wrote:So I need to edit 'CustomerTicketMessage.dtl' right?
yes
SantaPe wrote:I'm confused on where I need to add this code
I regret that it wasn't clear enough. Basically, I made an assumption that you'd find $('#Dest').bind in the dtl and apply the changes around it.
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

louis
OTRS newbie
Posts: 8
Joined: 20 May 2013, 16:51
OTRS Version?: 3.2.5
Real Name: Louis Allen

Re: How To show freetext for specific Queues for Customers

Post by louis » 23 May 2013, 14:12

Would it be possible to use something like this on the agent notes screen?

I would like to hide dynamic fields on the notes screen depending on the queue. I have had a go at adding some of the examples above in the AgentTicketActionCommon.dtl file but it doesn't seem to work correctly?

Code: Select all

	var queue = $('#Dest').val();
	window.alert(queue); # nothing seems to be displayed here????
	if(queue=='7\|\|Purchasing') {
		document.getElementById('DynamicField_Description').style.display =  'none';
		document.getElementById('LabelDynamicField_Description').style.display =  'none';
	}
	}

    });
Last edited by crythias on 17 Feb 2014, 16:58, edited 1 time in total.
Reason: [code] tags

louis
OTRS newbie
Posts: 8
Joined: 20 May 2013, 16:51
OTRS Version?: 3.2.5
Real Name: Louis Allen

Re: How To show freetext for specific Queues for Customers

Post by louis » 24 May 2013, 10:50

I can hide the elements successfully by using the follow javascript lines

document.getElementById('DynamicField_Description').style.display = 'none';
document.getElementById('LabelDynamicField_Description').style.display = 'none';

I just need to know how to conditionally hide them depending on what queue the ticket is in.

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

Re: How To show DynamicFields for specific Queues for Custom

Post by Giulio Soleni » 25 May 2013, 22:48

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>
 
Hi crythias, I am testing this code snippet on the 3.2.7 version and I found at least 3 issues that I addressed on the 3.1.* and now are there again:

1. Independently from the selected queue, when the customer click on "New ticket" to create a new ticket, the dynamic field is ALWAYS present and selectable. In other words it seems that the default "nonetext()" funcition is not applied when the form is opened.

2. document.compose.RichText.value = ""; (or document.compose.RichText.value = "dummy text"; in general) does not work anymore ... there is no way to pre-fill the body of the ticket with any text.

3. It's true that if I select a queue different from the one for which the dyn field is supposed to be used (Queue_Y in the example), the dyn field disappears, however, as soon as I select an attachment (or I delete an attachment) the dyn field appears again.

I think that 1. and 3. should be somehow related to the new way AJAX is used to refresh the form. I have no idea about the 2.

Does anyone have some new hints about?

thank you
Giulio
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.

User avatar
crythias
Moderator
Posts: 9981
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 May 2013, 04:22

The code you quoted won't hide until a queue is selected, which isn't ... horrible, I think. Especially since it's not usually the first thing you see.

To hide things on load, you can initiate the hide all at the bottom of the dtl:

Code: Select all

<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    Core.Agent.TicketAction.Init();
nonetext(); 
//]]></script>
<!--dtl:js_on_document_complete-->
 
Since this only gets loaded on refresh, not a big deal, though you could theoretically double-down on this and switch #Dest at the bottom and on change, as the attachment does a complete document refresh.
This adjusts for 1 and 3

For 2:

Code: Select all

    CKEDITOR.instances.RichText.setData( '<p>This is Line1</p><p>This is Line2</p>' ); 
wherever you need it within javascript.
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: 391
Joined: 30 Dec 2010, 14:35
OTRS Version?: 6.0.x and 5.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 26 May 2013, 13:11

crythias wrote: To hide things on load, you can initiate the hide all at the bottom of the dtl:
Since this only gets loaded on refresh, not a big deal, though you could theoretically double-down on this and switch #Dest at the bottom and on change, as the attachment does a complete document refresh.
This adjusts for 1 and 3
crythias wrote: For 2:

Code: Select all

    CKEDITOR.instances.RichText.setData( '<p>This is Line1</p><p>This is Line2</p>' ); 
wherever you need it within javascript.
Great! as usual :)
Still I would like to adjust the code a little bit more but It seems to work.
...I am also thinking about using some ACLs to limit the usage of undesired dynamic fields for some queues ... but I do not want to go out of topic.

Thank you very much
Giulio
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.

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

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 26 May 2013, 20:05

crythias wrote: This adjusts for 1 and 3
After some more tests ... unfortunately still one issue persists :(
If I select Queue_Y and then I set (or delete) an attachment the dyn field disappears.

I am trying to use checkDirty() to reset the form only in some conditions but the following snippet returns me an error:

Code: Select all

   if ( CKEDITOR.instances.Attachment.checkDirty() )
   {
      var r=confirm("Do you want to keep current data?");
      if (r==false)
      {
         document.getElementById('DynamicField_TicketFreeText1').style.display = 'none';
         document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'none';
      }
   }
... In general I did not understand why there are some part of the form (RichText) for which CKEDITOR calls can be used and some other for which CKEDITOR calls cannot.
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.

User avatar
crythias
Moderator
Posts: 9981
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 May 2013, 03:07

Giulio Soleni wrote:If I select Queue_Y and then I set (or delete) an attachment the dyn field disappears.
Because the whole page refreshes. You'll need to test for current Dest value and switch against it at the bottom of the page.
Giulio Soleni wrote:I am trying to use checkDirty() to reset the form...
CKEDITOR is only for the RichText field, not the whole form. Attachments is not a CKEDITOR instance.
The only applicable instance is RichText.

To do what you want means to overload the attachment scripting, which is not applicable to CKEDITOR.
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

tallesleonardo
OTRS newbie
Posts: 11
Joined: 23 May 2013, 03:25
OTRS Version?: versao 3.1.6
Location: Brasília, BRAZIL

Re: How To show freetext for specific Queues for Customers

Post by tallesleonardo » 27 May 2013, 22:54

Hi Crythias,
Sorry for my english, I'm Brazilian and I'm trying to implement OTRS.
I would wonder if there is any error in my code.

I'm putting DynamicField_TicketFreeText and the LabelDynamicField_TicketFreeText finished with ID Dynamic Field. Is that correct?

Code: Select all

<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
		
		
		function nonetext() {
			document.compose.Subject.value = "";
			document.compose.RichText.value = "";
			document.getElementById('DynamicField_TicketFreeText2').style.display = 'none';
			document.getElementById('LabelDynamicField_TicketFreeText2').style.display = 'none';
			document.getElementById('DynamicField_TicketFreeText7').style.display = 'none';
			document.getElementById('LabelDynamicField_TicketFreeText7').style.display = 'none';
			document.getElementById('DynamicField_TicketFreeText8').style.display = 'none';
			document.getElementById('LabelDynamicField_TicketFreeText8').style.display = 'none';
			
	}
		$('#Dest').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'PriorityID', 'ServiceID', 'SLAID',$Data{"DynamicFieldNamesStrg"}]);
    
	Core.Agent.TicketAction.Init();	
	var queue = $('#Dest').val();
	//window.alert(queue);
	if ( queue == "3\|\|CIA"){ 

	window.alert(queue);
	  document.getElementById('DynamicField_TicketFreeText2').style.display = 'block';
	  document.getElementById('LabelDynamicField_TicketFreeText2').style.display = 'block';
	  document.getElementById('LabelDynamicField_TicketFreeText2').className = 'Mandatory';
		document.getElementById('DynamicField_TicketFreeText2').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';
	  document.getElementById('DynamicField_TicketFreeText7').style.display = 'block';
      document.getElementById('LabelDynamicField_TicketFreeText7').style.display = 'block';
	  document.getElementById('LabelDynamicField_TicketFreeText7').className = 'Mandatory';
		document.getElementById('DynamicField_TicketFreeText7').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';
	  document.getElementById('DynamicField_TicketFreeText8').style.display = 'block';
      document.getElementById('LabelDynamicField_TicketFreeText8').style.display = 'block';
	  document.getElementById('LabelDynamicField_TicketFreeText8').className = 'Mandatory';
		document.getElementById('DynamicField_TicketFreeText8').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';
	  }
  
	});
//]]></script>


 
<!--dtl:js_on_document_complete-->
Talles Leonardo

User avatar
crythias
Moderator
Posts: 9981
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 » 28 May 2013, 13:24

tallesleonardo wrote:I would wonder if there is any error in my code.

I'm putting DynamicField_TicketFreeText and the LabelDynamicField_TicketFreeText finished with ID Dynamic Field. Is that correct?
Please ask your question in the other forums, such as help. This topic is overly long as it is, plus this HowTo forum is moderated, so it's tedious to approve conversations.

To answer your question: I can't answer your question. You would be able to determine if your code works or not: if it doesn't, you would be asking a different question; if it did work, you wouldn't be asking a question.
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: 391
Joined: 30 Dec 2010, 14:35
OTRS Version?: 6.0.x and 5.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 01 Jun 2013, 16:08

crythias wrote: Because the whole page refreshes. You'll need to test for current Dest value and switch against it at the bottom of the page.
... Ok, following your hints I have come to this code:
"inside" the CustomerTicketMessage.dtl

Code: Select all

<script type="text/javascript">//<![CDATA[

function nonetext() {
   document.compose.Subject.value = "";
   CKEDITOR.instances.RichText.setData( '' );
   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  "10\|\|Queue_A": // 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();
} // End switch

    });
//]]></script>
And at the end...

Code: Select all

<script type="text/javascript">//<![CDATA[
    Core.Customer.InitFocus();


switch ($('#Dest').val() ) {
    case  "10\|\|Queue_A": // 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();
} // End switch



//]]></script>
Now, however, if the customer first select Queue_A and then he changes idea and select another Queue without having specified any value for 'DynamicField_TicketFreeText1' custom attribute, he will not be able to submit his ticket at all, because - unexpectedly to me - once .className = 'Mandatory' has been set, it cannot be "unset" anymore :(

On the other hand, if the customer first select Queue_A and then he changes idea and select another Queue, this time having selected a value for if the customer first select Queue_A and then he changes idea and select another Queue, that value will remain set also for the ticket created in the other queue: in other words once the customer has gone through the selection of Queue_A and then he select another queue, it seems not possible to "unset" or set to a null value the 'DynamicField_TicketFreeText1' for all queues different than Queue_A.

I tryed to set something like:

Code: Select all

    default:
      nonetext();
      document.compose.DynamicField_TicketFreeText1.value = "";
with no result.
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.

User avatar
crythias
Moderator
Posts: 9981
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 Jun 2013, 17:31

in *theory*,

Code: Select all

delete document.getElementById("myField").value
will "undefine" the value for a field. Works on Chrome and likely Firefox. Not sure on IE.

http://perfectionkills.com/understanding-delete/

Re: Mandatory
It *can* be "unset"

Code: Select all

      document.getElementById('DynamicField_TicketFreeText1').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';

Code: Select all

      document.getElementById('DynamicField_TicketFreeText1').className = 'TicketFreeText  ServerError';
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: 391
Joined: 30 Dec 2010, 14:35
OTRS Version?: 6.0.x and 5.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 01 Jun 2013, 20:14

crythias wrote:Re: Mandatory
It *can* be "unset"

Code: Select all

      document.getElementById('DynamicField_TicketFreeText1').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';

Code: Select all

      document.getElementById('DynamicField_TicketFreeText1').className = 'TicketFreeText  ServerError';
The "unsetting" of mandatory works perfectly! :)
I put

Code: Select all

document.getElementById('DynamicField_TicketFreeText1').className = 'TicketFreeText ServerError';
just as a last line of nonetext() function and that's enough. Great!

Since I (and you also) was not sure about the "delete" statement for all browsers I used 2 ACLs to get to the same result:
Considering that TicketFreeText1 dyn field - for me - has a proper meaning for one queue only (Queue_A) used by one specific customer that may access to other 2 queues only (Queue_B, Queue_C) and that TicketFreeText1 otherwise should be hidden and unset for all other queues (the 'default' in the CustomerTicketMessage.dtl template) I set the following ACL in Config.pm

Code: Select all

$Self->{TicketAcl}->{'200-LimitTicketFreeText1'} = {
       Properties => {
                 Ticket => {
            Queue => ['Queue_B', 'Queue_C'],
         },
        },
       Possible => {
           Ticket => {
               DynamicField_TicketFreeText1 => [ ],
           },
       },
    };

    $Self->{TicketAcl}->{'250-LimitTicketFreeText1'} = {
       Properties => {
         Ticket => {
            Queue => ['Queue_A'],
         },

        },
       PossibleNot => {
           Ticket => {
               DynamicField_TicketFreeText1 => [ ],
           },
       },
    };
There is no need to specify other ACLs for all other queues since the "default" condition in the CustomerTicketMessage.dtl does all the job (it let the dyn field hidden, optional, and of course unset).

Thank you very much crythias for your help!!
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.

nyotrs
OTRS newbie
Posts: 17
Joined: 14 May 2013, 19:15
OTRS Version?: 3.2.6

Re: How To show freetext for specific Queues for Customers

Post by nyotrs » 10 Jun 2013, 20:08

Hi,

Am I the only one to notice that setting style.display = 'none' leaves some blank space on the page, how do we remove this? And I thought style.display = 'none' shouldn't leave any blank space.

Thanks!
OTRS 3.2.6

reneeb
OTRS guru
Posts: 4665
Joined: 13 Mar 2011, 09:54
OTRS Version?: 3.3.x
Company: Perl-Services.de
Contact:

Re: How To show freetext for specific Queues for Customers

Post by reneeb » 11 Jun 2013, 08:49

crythias wrote: It *can* be "unset"

Code: Select all

      document.getElementById('DynamicField_TicketFreeText1').className = 'TicketFreeText  Validate_RequiredDropdown ServerError';

Code: Select all

      document.getElementById('DynamicField_TicketFreeText1').className = 'TicketFreeText  ServerError';
This would be better written as

Code: Select all

$('#DynamicField_TicketFreeText1').removeClass('Validate_RequiredDropdown');
as this allows other add ons etc. to change the classes of the field, too. (and its more readable).
nyotrs wrote:Am I the only one to notice that setting style.display = 'none' leaves some blank space on the page, how do we remove this? And I thought style.display = 'none' shouldn't leave any blank space.
Instead of

Code: Select all

   document.getElementById('DynamicField_TicketFreeText1').style.display = 'none';
   document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'none';
You should use

Code: Select all

$('#DynamicField_TicketFreeText1').parent().addClass( 'Hidden' );
and instead of

Code: Select all

   document.getElementById('DynamicField_TicketFreeText1').style.display = 'block';
   document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'block';
you should use

Code: Select all

$('#DynamicField_TicketFreeText1').parent().removeClass( 'Hidden' );
The label and the field are wrapped by a "div" element. Thats why the extra space remains.
Perl / OTRS development: http://perl-services.de
Free OTRS add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de

nyotrs
OTRS newbie
Posts: 17
Joined: 14 May 2013, 19:15
OTRS Version?: 3.2.6

Re: How To show freetext for specific Queues for Customers

Post by nyotrs » 11 Jun 2013, 16:43

Hi reneeb,

Thanks! That got rid of the blank space ;-)
OTRS 3.2.6

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

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 15 Jun 2013, 20:42

reneeb wrote:
Instead of

Code: Select all

   document.getElementById('DynamicField_TicketFreeText1').style.display = 'none';
   document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'none';
You should use

Code: Select all

$('#DynamicField_TicketFreeText1').parent().addClass( 'Hidden' );
and instead of

Code: Select all

   document.getElementById('DynamicField_TicketFreeText1').style.display = 'block';
   document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'block';
you should use

Code: Select all

$('#DynamicField_TicketFreeText1').parent().removeClass( 'Hidden' );
The label and the field are wrapped by a "div" element. Thats why the extra space remains.
Thank you for the hint, reneeb. Following your suggestion I think that even cleaner it would be if we use

Code: Select all

$('#LabelDynamicField_TicketFreeText1').parent().removeClass( 'Hidden' );
instead of

Code: Select all

document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'block';
and

Code: Select all

$('#LabelDynamicField_TicketFreeText1').parent().addClass( 'Hidden' );
instead of

Code: Select all

document.getElementById('LabelDynamicField_TicketFreeText1').style.display = 'none';
or else the label of the dyn field remains at its place for every queue selection.
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.

nicole19890107
OTRS newbie
Posts: 31
Joined: 24 Jun 2013, 22:30
OTRS Version?: 3.2.6

Re: How To show freetext for specific Queues for Customers

Post by nicole19890107 » 12 Jul 2013, 20:36

Hello crythias,
I changed codes according to your example, but it didn't work: there's nothing happened when I selected the queue to "Junk"
Image
Like the picture shows, after I selected the queue(to) as "Junk", there's nothing happened.
my codes:

Code: Select all

 //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('ServiceID').style.display = 'none';
    break;
    default:
      document.compose.RichText.value = "Default"; //remove this. debug only. shows queue information
      
    }
// the following two lines are the existing last two lines of CustomerTicketMessage.dtl 

User avatar
crythias
Moderator
Posts: 9981
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 » 12 Jul 2013, 21:07

Please post questions in the "Help" forums as it is difficult to moderate questions in howtos.
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: 391
Joined: 30 Dec 2010, 14:35
OTRS Version?: 6.0.x and 5.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How To show freetext for specific Queues for Customers

Post by Giulio Soleni » 28 Jul 2013, 22:26

Giulio Soleni wrote: Since I (and you also) was not sure about the "delete" statement for all browsers I used 2 ACLs to get to the same result:
Considering that TicketFreeText1 dyn field - for me - has a proper meaning for one queue only (Queue_A) used by one specific customer that may access to other 2 queues only (Queue_B, Queue_C) and that TicketFreeText1 otherwise should be hidden and unset for all other queues (the 'default' in the CustomerTicketMessage.dtl template) I set the following ACL in Config.pm

Code: Select all

$Self->{TicketAcl}->{'200-LimitTicketFreeText1'} = {
       Properties => {
                 Ticket => {
            Queue => ['Queue_B', 'Queue_C'],
         },
        },
       Possible => {
           Ticket => {
               DynamicField_TicketFreeText1 => [ ],
           },
       },
    };

    $Self->{TicketAcl}->{'250-LimitTicketFreeText1'} = {
       Properties => {
         Ticket => {
            Queue => ['Queue_A'],
         },

        },
       PossibleNot => {
           Ticket => {
               DynamicField_TicketFreeText1 => [ ],
           },
       },
    };
There is no need to specify other ACLs for all other queues since the "default" condition in the CustomerTicketMessage.dtl does all the job (it let the dyn field hidden, optional, and of course unset).
I have adjusted the ACLs considering a more generic condition: I did not specify that in my company all used queues have a format CUSTOMER1::Queue_A, CUSTOMER1::Queue_B, ... CUSTOMER2::Queue_Y, CUSTOMER2::Queue_W, etc.
So in my first ACL I would like to specify all queues that starts with MYCUSTOMER:: but for queue MYCUSTOMER::Queue_A, while the second ACL is just for the specific MYCUSTOMER::Queue_A.

Code: Select all

$Self->{TicketAcl}->{'200-LimitTicketFreeText1'} = {
# DISABLE TicketFreeText1 FOR ALL CUSTOMER::* QUEUES BUT FOR CUSTOMER::Queue_A
        Properties => {
                Queue => {
                        # All MYCUSTOMER:: queues but MYCUSTOMER::Queue_A
                        Name => ['[RegExp]^(?!.*Queue_A)MYCUSTOMER::.*'],
                }
        },
        Possible => {
                Ticket => {
                        DynamicField_TicketFreeText1 => [ ],
                },
        },
};

$Self->{TicketAcl}->{'250-LimitTicketFreeText1'} = {
# ENABLE TicketFreeText1 FOR MYCUSTOMER::Queue_A QUEUE
        Properties => {
                Ticket => {
                        Queue => ['MYCUSTOMER::Queue_A'],
                },
        },
        PossibleNot => {
                Ticket => {
                        DynamicField_TicketFreeText1 => [ ],
                },
        },
};
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.

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 » 17 Feb 2014, 10:53

Hi Cythias,
I config file CustomerTicketMessage.dtl on OTRS 3.1.7, it's working. But when I upgrade to OTRS 3.3.4, it's not working.
When I select Queue, it does not show dynamic field. How can I fix it? Pls help me.
This is my code:

Code: Select all

function nonetext() {
   
   document.getElementById('DynamicField_1').style.display = 'none';
   document.getElementById('LabelDynamicField_1').style.display = 'none';
   document.getElementById('DynamicField_2').style.display = 'none';
   document.getElementById('LabelDynamicField_2').style.display = 'none';
   document.getElementById('DynamicField_3').style.display = 'none';
   document.getElementById('LabelDynamicField_3').style.display = 'none';
   document.getElementById('DynamicField_4').style.display = 'none';
   document.getElementById('LabelDynamicField_4').style.display = 'none';
   document.getElementById('DynamicField_5').style.display = 'none';
   document.getElementById('LabelDynamicField_5').style.display = 'none';
   document.getElementById('DynamicField_6').style.display = 'none';
   document.getElementById('LabelDynamicField_6').style.display = 'none';
   document.getElementById('DynamicField_7').style.display = 'none';
   document.getElementById('LabelDynamicField_7').style.display = 'none';

}

switch ($('#Dest').val() ) {
    case  "6\|\|H&B Helpdesk HCM": 
      document.compose.Subject.value = "H&B Helpdesk HCM!";
      document.compose.RichText.value ="Thank you for using OTRS!";

      document.getElementById('DynamicField_1').style.display = 'block';
      document.getElementById('LabelDynamicField_1').style.display = 'block';
      document.getElementById('DynamicField_1').className = 'DynamicField  Validate_RequiredDropdown ServerError';
      
      document.getElementById('DynamicField_2').style.display = 'block';
      document.getElementById('LabelDynamicField_2').style.display = 'block';
      document.getElementById('DynamicField_2').className = 'DynamicField  Validate_RequiredDropdown ServerError';
      
      document.getElementById('DynamicField_3').style.display = 'block';
      document.getElementById('LabelDynamicField_3').style.display = 'block';
      document.getElementById('DynamicField_3').className = 'DynamicField  Validate_RequiredDropdown ServerError';

      document.getElementById('DynamicField_4').style.display = 'block';
      document.getElementById('LabelDynamicField_4').style.display = 'block';

      document.getElementById('DynamicField_5').style.display = 'block';
      document.getElementById('LabelDynamicField_5').style.display = 'block';

      document.getElementById('DynamicField_6').style.display = 'block';
      document.getElementById('LabelDynamicField_6').style.display = 'block';

      document.getElementById('DynamicField_7').style.display = 'block';
      document.getElementById('LabelDynamicField_7').style.display = 'block';
      document.getElementById('DynamicField_7').className = 'DynamicField  Validate_RequiredDropdown ServerError';

      
   break;
   
case  "7\|\|H&B Helpdesk HN": 
      document.compose.Subject.value = "H&B Helpdesk HN!";
      document.compose.RichText.value ="Thank you for using OTRS!";
      document.getElementById('DynamicField_1').style.display = 'block';
      document.getElementById('LabelDynamicField_1').style.display = 'block';
      document.getElementById('DynamicField_1').className = 'DynamicField  Validate_RequiredDropdown ServerError';
      
      document.getElementById('DynamicField_2').style.display = 'block';
      document.getElementById('LabelDynamicField_2').style.display = 'block';
      document.getElementById('DynamicField_2').className = 'DynamicField  Validate_RequiredDropdown ServerError';
      
      document.getElementById('DynamicField_3').style.display = 'block';
      document.getElementById('LabelDynamicField_3').style.display = 'block';
      document.getElementById('DynamicField_3').className = 'DynamicField  Validate_RequiredDropdown ServerError';

      document.getElementById('DynamicField_4').style.display = 'block';
      document.getElementById('LabelDynamicField_4').style.display = 'block';

      document.getElementById('DynamicField_5').style.display = 'block';
      document.getElementById('LabelDynamicField_5').style.display = 'block';

      document.getElementById('DynamicField_6').style.display = 'block';
      document.getElementById('LabelDynamicField_6').style.display = 'block';

      document.getElementById('DynamicField_7').style.display = 'block';
      document.getElementById('LabelDynamicField_7').style.display = 'block';
      document.getElementById('DynamicField_7').className = 'DynamicField  Validate_RequiredDropdown ServerError';

   break;

    default:
      nonetext();
}
Last edited by crythias on 17 Feb 2014, 16:54, edited 1 time in total.
Reason: code tags

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 » 19 Feb 2014, 08:59

Anyone can help me? Pls
kp20mar wrote:Hi Cythias,
I config file CustomerTicketMessage.dtl on OTRS 3.1.7, it's working. But when I upgrade to OTRS 3.3.4, it's not working.
When I select Queue, it does not show dynamic field. How can I fix it? Pls help me.
This is my code:

Code: Select all

function nonetext() {
   
   document.getElementById('DynamicField_1').style.display = 'none';
   document.getElementById('LabelDynamicField_1').style.display = 'none';
   document.getElementById('DynamicField_2').style.display = 'none';
   document.getElementById('LabelDynamicField_2').style.display = 'none';
   document.getElementById('DynamicField_3').style.display = 'none';
   document.getElementById('LabelDynamicField_3').style.display = 'none';
   document.getElementById('DynamicField_4').style.display = 'none';
   document.getElementById('LabelDynamicField_4').style.display = 'none';
   document.getElementById('DynamicField_5').style.display = 'none';
   document.getElementById('LabelDynamicField_5').style.display = 'none';
   document.getElementById('DynamicField_6').style.display = 'none';
   document.getElementById('LabelDynamicField_6').style.display = 'none';
   document.getElementById('DynamicField_7').style.display = 'none';
   document.getElementById('LabelDynamicField_7').style.display = 'none';

}

switch ($('#Dest').val() ) {
    case  "6\|\|H&B Helpdesk HCM": 
      document.compose.Subject.value = "H&B Helpdesk HCM!";
      document.compose.RichText.value ="Thank you for using OTRS!";

      document.getElementById('DynamicField_1').style.display = 'block';
      document.getElementById('LabelDynamicField_1').style.display = 'block';
      document.getElementById('DynamicField_1').className = 'DynamicField  Validate_RequiredDropdown ServerError';
      
      document.getElementById('DynamicField_2').style.display = 'block';
      document.getElementById('LabelDynamicField_2').style.display = 'block';
      document.getElementById('DynamicField_2').className = 'DynamicField  Validate_RequiredDropdown ServerError';
      
      document.getElementById('DynamicField_3').style.display = 'block';
      document.getElementById('LabelDynamicField_3').style.display = 'block';
      document.getElementById('DynamicField_3').className = 'DynamicField  Validate_RequiredDropdown ServerError';

      document.getElementById('DynamicField_4').style.display = 'block';
      document.getElementById('LabelDynamicField_4').style.display = 'block';

      document.getElementById('DynamicField_5').style.display = 'block';
      document.getElementById('LabelDynamicField_5').style.display = 'block';

      document.getElementById('DynamicField_6').style.display = 'block';
      document.getElementById('LabelDynamicField_6').style.display = 'block';

      document.getElementById('DynamicField_7').style.display = 'block';
      document.getElementById('LabelDynamicField_7').style.display = 'block';
      document.getElementById('DynamicField_7').className = 'DynamicField  Validate_RequiredDropdown ServerError';

      
   break;
   
case  "7\|\|H&B Helpdesk HN": 
      document.compose.Subject.value = "H&B Helpdesk HN!";
      document.compose.RichText.value ="Thank you for using OTRS!";
      document.getElementById('DynamicField_1').style.display = 'block';
      document.getElementById('LabelDynamicField_1').style.display = 'block';
      document.getElementById('DynamicField_1').className = 'DynamicField  Validate_RequiredDropdown ServerError';
      
      document.getElementById('DynamicField_2').style.display = 'block';
      document.getElementById('LabelDynamicField_2').style.display = 'block';
      document.getElementById('DynamicField_2').className = 'DynamicField  Validate_RequiredDropdown ServerError';
      
      document.getElementById('DynamicField_3').style.display = 'block';
      document.getElementById('LabelDynamicField_3').style.display = 'block';
      document.getElementById('DynamicField_3').className = 'DynamicField  Validate_RequiredDropdown ServerError';

      document.getElementById('DynamicField_4').style.display = 'block';
      document.getElementById('LabelDynamicField_4').style.display = 'block';

      document.getElementById('DynamicField_5').style.display = 'block';
      document.getElementById('LabelDynamicField_5').style.display = 'block';

      document.getElementById('DynamicField_6').style.display = 'block';
      document.getElementById('LabelDynamicField_6').style.display = 'block';

      document.getElementById('DynamicField_7').style.display = 'block';
      document.getElementById('LabelDynamicField_7').style.display = 'block';
      document.getElementById('DynamicField_7').className = 'DynamicField  Validate_RequiredDropdown ServerError';

   break;

    default:
      nonetext();
}

User avatar
crythias
Moderator
Posts: 9981
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 Feb 2014, 16:08

Howto is not for questions. This is a moderated forum and back-n-forth is a pain to administer.
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

dtosun
OTRS newbie
Posts: 24
Joined: 12 Sep 2012, 14:00
OTRS Version?: 4.0.13
Real Name: Dursun Tosun

Re: How To show freetext for specific Queues for Customers

Post by dtosun » 09 Jul 2014, 11:32

Is it possible to do it for AgentTicketClose.dtl?

rl0infeck
OTRS newbie
Posts: 4
Joined: 28 Jan 2011, 13:56
OTRS Version?: 3.05

Re: How To show freetext for specific Queues for Customers

Post by rl0infeck » 05 Aug 2014, 10:00

crythias wrote:The code you quoted won't hide until a queue is selected, which isn't ... horrible, I think. Especially since it's not usually the first thing you see.

To hide things on load, you can initiate the hide all at the bottom of the dtl:

Code: Select all

<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    Core.Agent.TicketAction.Init();
nonetext(); 
//]]></script>
<!--dtl:js_on_document_complete-->
Since this only gets loaded on refresh, not a big deal, though you could theoretically double-down on this and switch #Dest at the bottom and on change, as the attachment does a complete document refresh.
This adjusts for 1 and 3

For 2:

Code: Select all

    CKEDITOR.instances.RichText.setData( '<p>This is Line1</p><p>This is Line2</p>' );
wherever you need it within javascript.

Could you tell me how you resolve problem number 3 (attachment)

rtocci62
OTRS newbie
Posts: 15
Joined: 29 Jul 2013, 11:07
OTRS Version?: 3.0.10

Re: How To show freetext for specific Queues for Customers

Post by rtocci62 » 13 May 2015, 18:15

Hi crythias the function
CKEDITOR.instances.RichText.setData( '<p>This is Line1</p><p>This is Line2</p>' );
does not work the value of richtext is always to load AgentTicketPhone.
While the dynamic fields work fine , any idea?

OTRS 3.0.10

Post Reply