OTRS – Completely hide “disabled” Services

OTRS — Jeff Eske on April 25, 2012 at 3:26 pm

In OTRS 3.1 and newer, evidently Services that are disabled via ACLs are now only greyed out.  For our users, it’s less confusing to make them disappear completely.  In order to accomplish this, I had to actually go into a couple of files and add some code.  See the description below.
Files Modified:
/opt/otrs/Kernel/Modules/AgentTicketEmail.pm
/opt/otrs/Kernel/Modules/AgentTicketPhone.pm

Modifications:
You need to add an else statement (the push part exists without the else part)down around:
AgentTicketEmail.pm – line 1950-1955.
AgentTicketPhone.pm – line 1875-1885.

[CODE:]
# check if service is disabled
if ( !$Service{$ServiceKey} ) {
$ServiceRegister{Disabled} = 1;
}
##### Else Brackets Added by Jeff #####
 else{
push @ServiceList, \%ServiceRegister;
}
# set service as printed
$AddedServices{$ServiceKey} = 1;

[/CODE:]

Jeff

OTRS – Show/Hide Dynamic Fields based on Service

OTRS — Jeff Eske on April 25, 2012 at 3:13 pm

PLEASE NOTE:  I’ve changed employers and have moved on to other projects.  I no longer use OTRS, or have access to OTRS, so I won’t really be able to help you beyond what I’ve already posted here. 

Jeff

With OTRS 3.1 and higher, you can create dynamic fields (formerly freetext fields) to allow collection of additional information beyond the defaults.  Normally, these fields show up in every ticket that they’ve been setup to show in.  I wanted to be able to hide the fields and then only show them when a particular Service or Services were chosen.  I’ve listed what I did below.
Files Modified:

/opt/otrs/Kernel/Output/HTML/Standard/AgentTicketEmail.dtl
/opt/otrs/Kernel/Output/HTML/Standard/AgentTicketPhone.dtl

Modifications made:

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

[CODE:]
<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>
[/CODE:]

Then I added the “id name” to the Dynamic Field that I wanted to Show/Hide:

[CODE:]
<!– dtl:block:DynamicField_FieldName –>
<div id=”id name” style=”display:none;” class=”Row Row_DynamicField_$QData{“Name”}”>
$Data{“Label”}
<div>
$Data{“Field”}
</div>
<div></div>
</div>
<!– dtl:block:DynamicField_FieldName –>
[/CODE:]

Now, by default, the dynamic field is hidden. When you choose a Service with the ServiceID or 2 or 3, it automagically appears!

Jeff Eske

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. | Jeff's Blog