This is an updated version that I tested for
version 5.0.x
To test the model I defined the following items:
- definition of the following 6 queues:
"ACME01::Queue1" ... queue-id: 10
"ACME01::Queue2" ... queue-id: 11
"ACME01::Queue3" ... queue-id: 12
"ACME02::Queue1" ... queue-id: 20
"ACME02::Queue2" ... queue-id: 21
"ACME02::Queue3" ... queue-id: 22
Needless to say the queue-id's and the names of the queues may change for your specific system and that you have to adjust the CustomerTicketMessage.tt file as well.
- definition of three example dynamic fields:
myDropDown01 : as a drop down fileld
myTextField01 : as a free text field
myTextField02 : as a free text field
Again, these are just examples that you may change to suit your needs
All these fields must be defined in SysConfig Ticket -> Frontend::Customer::Ticket::ViewNew under "Ticket::Frontend::CustomerTicketMessage###DynamicField" parameter.
Please mind that ALL of them must be defined with content "1" (that is optional), and NEVER "2" (that is mandatory) because they will be defined as mandatory within the CustomerTicketMessage.tt template file only for some queues.
Then, here is my personalization of the
"Queue" block of
/opt/otrs/Custom/Kernel/Output/HTML/Templates/Standard/CustomerTicketMessage.tt
template file.
You should replace all the stuff between the two statements
Code: Select all
[% RenderBlockStart("Queue") %]
...
[% RenderBlockEnd("Queue") %]
with the code specified here below...
Mind not to change the original /opt/otrs/Kernel/Output/HTML/Templates/Standard/CustomerTicketMessage.tt template, but take a copy instead and edit the /opt/otrs/
Custom... file for your needs.
Given the specifics above, the logic that rules my example is the following:
A) myDropDown01 is available and mandatory only for ACME01::Queue1
B) myTextField01 is available and mandatory for ACME02::Queue2 and ACME02::Queue3
C) myTextField02 is available and mandatory only for ACME02::Queue3
D) ACME01::Queue1 and ACME02::Queue1 queues have a subject and body already filled out
Code: Select all
[% RenderBlockStart("Queue") %]
<div>
<label for="Dest" class="Mandatory">
<span class="Marker">*</span>
[% Translate("To") | html %]:
</label>
[% Data.ToStrg %]
<div id="DestError" class="TooltipErrorMessage" ><p>[% Translate("This field is required.") | html %]</p></div>
<div id="DestServerError" class="TooltipErrorMessage NoJavaScriptMessage[% Data.QueueInvalid | html %]" ><p>[% Translate("This field is required.") | html %]</p></div>
<div class="Clear"></div>
</div>
[% WRAPPER JSOnDocumentComplete %]
<script type="text/javascript">//<![CDATA[
//// START EDIT
//// myDropDown01 is available and mandatory only for ACME01::Queue1
//// myTextField01 is available and mandatory for ACME02::Queue2 and ACME02::Queue3
//// myTextField02 is available and mandatory only for ACME02::Queue3
//// ACME01::Queue1 and ACME02::Queue1 queues have a subject and body already filled out
$(document).ready(function() {
function hideDynFields() {
$("[id^=DynamicField]").parent().hide();
$("[id^=LabelDynamicField]").parent().hide();
$("[id^=DynamicField]").removeClass('Validate_Required');
}
function initText(subValue,bodyValue) {
var thisSubject = $('#Subject').val();
var thisRichText = CKEDITOR.instances.RichText.getData() ;
var sbjLen = thisSubject.length;
var textLen = thisRichText.length;
var totLen = sbjLen*1 + textLen*1;
if (totLen == 0)
{
document.compose.Subject.value = subValue;
CKEDITOR.instances.RichText.setData( bodyValue, function() {this.checkDirty();});
}
else
{
var r=confirm("Click Ok to keep the data, or Cancel to load the default body and subject");
if (r==false)
{
document.compose.Subject.value = subValue;
CKEDITOR.instances.RichText.setData( bodyValue, function() {this.checkDirty();});
}
}
hideDynFields();
}
function selectQueues() {
switch ($('#Dest').val() ) {
case "10||ACME01::Queue1":
initText('ACME01::Queue1 subject','<B>ACME01::Queue1</B> <br/>body... <br/>blah... <br/>blah... <br/>');
$("[id^=DynamicField_myDropDown01]").parent().show();
$("[id^=LabelDynamicField_myDropDown01]").parent().show();
document.getElementById('DynamicField_myDropDown01').className = 'TicketFreeText Validate_Required ServerError';
break;
case "20||ACME02::Queue1":
initText('ACME02::Queue1 subject','<B>ACME02::Queue1</B> <br/>body... <br/>blah... <br/>blah... <br/>');
break;
case "21||ACME02::Queue2":
initText('','');
$("[id^=DynamicField_myTextField01]").parent().show();
$("[id^=LabelDynamicField_myTextField01]").parent().show();
document.getElementById('DynamicField_myTextField01').className = 'TicketFreeText Validate_Required ServerError';
break;
case "22||ACME02::Queue3":
initText('','');
$("[id^=DynamicField_myTextField01]").parent().show();
$("[id^=LabelDynamicField_myTextField01]").parent().show();
$("[id^=DynamicField_myTextField02]").parent().show();
$("[id^=LabelDynamicField_myTextField02]").parent().show();
document.getElementById('DynamicField_myTextField01').className = 'TicketFreeText Validate_Required ServerError';
document.getElementById('DynamicField_myTextField02').className = 'TicketFreeText Validate_Required ServerError';
break;
default:
initText('','');
} // End switch
} // End selectQueues
$('#Dest').bind('change', function (Event) {
Core.AJAX.FormUpdate($('#NewCustomerTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'PriorityID', 'ServiceID', 'SLAID', [% Data.DynamicFieldNamesStrg %]]);
selectQueues();
});
selectQueues();
}); // End document ready
//// END EDIT
//]]></script>
[% END %]
[% RenderBlockEnd("Queue") %]
After you made all the changes, I suggest to run a /opt/otrs/bin/otrs.SetPermissions.pl (with the parameters according to your Operating system) to be sure that the customized files take the correct permissions and ownership.
Also run a:
Code: Select all
su -c "/opt/otrs/bin/otrs.Console.pl Maint::Config::Rebuild" -s /bin/bash otrs
to rebuild your configuration.
enjoy
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.