[SOLVED] Show/Hide Dynamic Field Based on Service

Moderator: crythias

Locked
jeske
Znuny newbie
Posts: 10
Joined: 10 Jan 2012, 17:44
Znuny Version: 3.1.2
Real Name: jeff
Company: Creighton University
Location: Creighton University, Omaha, NE
Contact:

[SOLVED] Show/Hide Dynamic Field Based on Service

Post by jeske »

Hi All,

I'm trying to setup my New Phone Ticket so that some dynamic fields only show when a particular Service or SLA is chosen. I've found the posts on here dealing with freetext fields showing for certain queues, etc. but I'm unsure of how I need to go about changing things to work for dynamic fields, rather than freetext fields.

Should it be as easy as just replacing TicketFreeText with DynamicField?

I've changed:
document.getElementById('TicketFreeText1').style.display = 'block';

To be:
document.getElementById('DynamicField_MyFieldName').style.display = 'block'; ?

I've tried that and it doesn't work for me, so I'm assuming that it will require more than that.

Thanks in advance.

Jeff
OTRS 3.1 on Linux with MySQL database connected to an Active Directory for Agents and Customers.
jeske
Znuny newbie
Posts: 10
Joined: 10 Jan 2012, 17:44
Znuny Version: 3.1.2
Real Name: jeff
Company: Creighton University
Location: Creighton University, Omaha, NE
Contact:

Re: [SOLVED] Show/Hide Dynamic Field Based on Service

Post by jeske »

I was eventually able to get it worked out.

In AgentTicketPhone.dtl and AgentTicketEmail.dtl, I added some code in the section where it checks if the Service is changed:

Code: Select all

<script type="text/javascript">//<![CDATA[
    $('#ServiceID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'ServiceID', ['TypeID', 'Dest', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
    });
############  Added by Jeff ##############
#Core.Agent.InitFocus();
switch ($('#ServiceID').val() ) {
	case  "2":
		document.getElementById('id name').style.display = 'block';
        break;
	case  "3":
		document.getElementById('id name').style.display = 'block';
        break;
	default:
		document.getElementById('id name').style.display = 'none';
}
 
#########  End - Added by Jeff ###########
    });
//]]></script>
Then I added the "id name" to the Dynamic Field that I wanted to Show/Hide:

Code: Select all

<!-- dtl:block:DynamicField_MyFieldName -->
                    <div id="id name" style="display:none;" class="Row Row_DynamicField_$QData{"Name"}">
                        $Data{"Label"}
                        <div id="id name" class="Field">
                            $Data{"Field"}
                        </div>
                        <div id="id name" style="display:none;" class="Clear"></div>
                    </div>
<!-- dtl:block:DynamicField_MyFieldName -->
Now, by default, the dynamic field is hidden. When you choose a Service with the ServiceID or 2 or 3, it automagically appears!

Jeff
OTRS 3.1 on Linux with MySQL database connected to an Active Directory for Agents and Customers.
kiki
Znuny newbie
Posts: 6
Joined: 05 May 2012, 23:34
Znuny Version: 3.1.1

Re: [SOLVED] Show/Hide Dynamic Field Based on Service

Post by kiki »

Hi everyone, please, I'm new on OTRS and I would like to know if this code worked for anyone? does not work for me and I do not know what else I should do, someone could direct me. thanks in advance.
Locked