Show different FormFields by Qeue-Selection - CUSTOMER

Moderator: crythias

Locked
DasaTech
Znuny newbie
Posts: 3
Joined: 22 Mar 2012, 11:28
Znuny Version: 31200

Show different FormFields by Qeue-Selection - CUSTOMER

Post by DasaTech »

Hello to You,

i know, that this problem is mentioned in some threads here in the English and the German Forum. I have tried for some days to get a solution that will work for me - but till now i dont have a solution... I have read Threads, change codes, and so on... I think i have to give up.

I'm new in OTRS and before i checked it, that the FreeTextFields will be invalid till OTRS 3.1 (now DynamicFields) i went the wrong way to deal with. I have found a HowTo in the English Forum:

viewtopic.php?f=60&t=8032

On the beginning of the thread the problem will be solved with the old FreeTextFields. But later on the thread someone (thx to Giulio Soleni) changed the code for the new DynamicFields. It is explained OK - but the code dont work for me. Perhaps I have a thinking error in doing this...therefore i write this Thread... :-( ...maybe someon here, who is more professional, can help me.

Like mentioned in the title i would like to show individual form-fields in the customer frontend by selecting the qeue.

Version of OTRS: 3.1.2

For testing i established 4 Mainqeues an 1 Subqeue:

Altglas
Kunststoff
Kunststoff::ASA
Metalle
Postmaster

The following Code was copied into the "CustomerTicketMessage.dtl":

Code: Select all

    <!--dtl:js_on_document_complete-->
    <script type="text/javascript">//<![CDATA[
        $('#TypeID').bind('change', function (Event) {
            // make sure the ticket is not yet created on queue change
            $('input#Expand').val(1);
            Core.Form.Validate.DisableValidation($(this).closest('form'));
            $(this).closest('form').submit();
        });
       
    ----->HERE IS THE CODE MENTIONED ABOVE<-----   

    //]]></script>
    <!--dtl:js_on_document_complete-->
This is the code that i have copied into the area (see above)

Code: Select all

function nonetext() {
   document.compose.Subject.value = "";
   document.compose.RichText.value = "";
   document.getElementById('DynamicField_Metalltyp').style.display = 'none';
   document.getElementById('LabelDynamicField_Metalltyp').style.display = 'none';
   document.getElementById('DynamicField_Glastyp').style.display = 'none';
   document.getElementById('LabelDynamicField_Glastyp').style.display = 'none';
   document.getElementById('DynamicField_Kunststofftyp').style.display = 'none';
   document.getElementById('LabelDynamicField_Kunststofftyp').style.display = 'none';
}

switch ($('#Dest').val() ) {
   case  "2\|\|Metalle": // need to slash escape the pipes
      nonetext();
      document.getElementById('DynamicField_Metalltyp').style.display = 'block';
      document.getElementById('LabelDynamicField_Metalltyp').style.display = 'block';
      document.getElementById('DynamicField_Metalltyp').className = 'Validate_Required';
   break;
   case  "3\|\|Altglas": // need to slash escape the pipes
      nonetext();
      document.getElementById('DynamicField_Glastyp').style.display = 'block';
      document.getElementById('LabelDynamicField_Glastyp').style.display = 'block';
	  document.getElementById('DynamicField_Glastyp').className = 'Validate_Required';
   break;
   case  "4\|\|Kunststoff": // need to slash escape the pipes
      nonetext();
      document.getElementById('DynamicField_Kunststofftyp').style.display = 'block';
      document.getElementById('LabelDynamicField_Kunststofftyp').style.display = 'block';
      document.getElementById('DynamicField_Kunststofftyp').className = 'Validate_Required';
   break;

   
    default:
      nonetext();
}	
But nothing happens on the customer template in frontend by choosing the different qeues.

I would be very happy for tips, solutions or hints...

Greetz
Giulio Soleni
Znuny wizard
Posts: 392
Joined: 30 Dec 2010, 14:35
Znuny Version: 6.0.x and 5.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: Show different FormFields by Qeue-Selection - CUSTOMER

Post by Giulio Soleni »

Hallo,
three questions... (maybe it's obvious, but... :) )
1 - did you define your dynamic fields via ADMIN - Ticket Settings area > Dynamic Fields on the Admin web interface?
2 - did you activate your defined dinamic fields for the Customer frontend?
For this second configuration edit SysConfig Settings in Ticket -> Frontend::Customer::Ticket::ViewNew
on the last parameter shown (Ticket::Frontend::CustomerTicketMessage###DynamicField) add all the dyn fields you have defined setting key = dynfield name and Content = 1.
3 - did you double checked the queue-id numbers in your CustomerTicketMessage.dtl customisation?

I have an update of the customisation though ... I'll post here and in the original howto as soon as I have tested a little bit more :)
ciao ^^
Giulio

Edit: This is the link to the update I said here above:
viewtopic.php?f=60&t=8032#p66824
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.
Locked