Hi crythiascrythias wrote:OK, so I enabled it here: Edit Config Settings in Ticket -> Core::Ticket
So, that (my?) code at the bottom? before the end of the script, you can do something like this:
Understand that your logic has to have some boundaries of "does it make sense to do this?" Because a Queue that changes a Type that changes a Queue... Or something else, like: Why does the Queue always change back to Junk? Why can't I change that separately?Code: Select all
switch ($('#TypeID').val() ) { case "1": document.getElementById('Dest').value = '3\|\|Junk'; break; default: }
What if you wanted to change the Queue list by changing the Type? ... whew. You have to ask some hard questions, don't you? http://www.javascriptkit.com/javatutors ... tent.shtml
The best (?) option is to do some array storage of the list, clear the list, and add the entries you want to show. Don't forget that if you are using Dest (Queues), you must slash escape the pipes when referencing them.
I tried to use your suggestion to automatically set the right queue after the customer selected a ticket type, but it's not work.
I modified the custom copy of CustomerTicketMessage.dtl including at the bottom of file the modified block of code but despite what is the ticket type selected, the case statement goes to the default option, setting the queue to 'raw'.
What I miss or it's wrong in my code ?
regards
stefano
Following the code :
------------------------------------------------------------------------------------------------------------------
Code: Select all
# --
# CustomerTicketMessage.dtl - provides HTML form for customer message
# Copyright (C) 2001-2010 xxx, http://otrs.org/
# --
# $Id: CustomerTicketMessage.dtl,v 1.59 2010/12/03 13:45:54 martin Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
<div id="MainBox" class="TicketCompose ARIARoleMain">
<div class="Content">
<form action="$Env{"CGIHandle"}" method="post" name="compose" enctype="multipart/form-data" class="Validate PreventMultipleSubmits">
<input type="hidden" name="Action" value="$Env{"Action"}" />
<input type="hidden" name="Subaction" value="StoreNew" />
<input type="hidden" name="Expand" id="Expand" value="" />
<input type="hidden" name="FormID" value="$QData{"FormID"}" />
<fieldset class="TableLike FixedLabelSmallBi">
<!-- dtl:block:TicketType -->
<div>
<!--<label for="TicketNumber">$Config{"Ticket::Hook"}</label>
<input title="Ticket#" type="text" name="TicketNumber" size="30" value="$QData{"TicketNumber"}" />-->
<label for="TypeID" class="Mandatory">
<span class="Marker">*</span>
$Text{"Tipo richiesta"}:
</label>
$Data{"TypeStrg"}
<div id="DestError" class="TooltipErrorMessage" ><p>$Text{"This field is required."}</p></div>
<div id="DestServerError" class="TooltipErrorMessage NoJavaScriptMessage$QData{"TypeInvalid"}" ><p>$Text{"This field is required."}</p></div>
<div class="Clear"></div>
</div>
<!--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();
});
//]]></script>
<!--dtl:js_on_document_complete-->
<!-- dtl:block:TicketType -->
<!-- dtl:block:Queue -->
<div>
<label for="Dest" class="Mandatory">
<span class="Marker">*</span>
$Text{"To"}:
</label>
$Data{"ToStrg"}
<div id="DestError" class="TooltipErrorMessage" ><p>$Text{"This field is required."}</p></div>
<div id="DestServerError" class="TooltipErrorMessage NoJavaScriptMessage$QData{"QueueInvalid"}" ><p>$Text{"This field is required."}</p></div>
<div class="Clear"></div>
</div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
$('#Dest').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();
});
//]]></script>
<!--dtl:js_on_document_complete-->
<!-- dtl:block:Queue -->
<!-- dtl:block:TicketService -->
<div>
<label for="ServiceID">$Text{"Service"}:</label>
$Data{"ServiceStrg"}
<div class="Clear"></div>
</div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
$('#ServiceID').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();
});
//]]></script>
<!--dtl:js_on_document_complete-->
<!-- dtl:block:TicketService -->
<!-- dtl:block:TicketSLA -->
<div>
<label for="SLAID" title="$Text{"Service level agreement"}">$Text{"SLA"}:</label>
$Data{"SLAStrg"}
<div class="Clear"></div>
</div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
$('#SLAID').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();
});
//]]></script>
<!--dtl:js_on_document_complete-->
<!-- dtl:block:TicketSLA -->
<div>
<label for="Subject" class="Mandatory">
<span class="Marker">*</span>
$Text{"Subject"}:
</label>
<input title="Subject" type="text" id="Subject" name="Subject" value="$QData{"Subject"}" class="Validate_Required $QData{"SubjectInvalid"}" />
<div id="SubjectError" class="TooltipErrorMessage" ><p>$Text{"This field is required."}</p></div>
<div id="SubjectServerError" class="TooltipErrorMessage NoJavaScriptMessage$QData{"SubjectInvalid"}" ><p>$Text{"This field is required."}</p></div>
<div class="Clear"></div>
</div>
<div class="RichTextHolder">
<label for="RichText" class="Mandatory">
<span class="Marker">*</span>
$Text{"Text"}:
</label>
<div class="Clear"></div>
<!-- dtl:block:RichText -->
$Include{"CustomerRichTextEditor"}
<!-- dtl:block:RichText -->
<textarea id="RichText" class="RichText Validate_Required $QData{"BodyInvalid"}" name="Body" rows="15" cols="$Config{"Ticket::Frontend::TextAreaNote"}">$QData{"Body"}</textarea>
<div id="RichTextError" class="TooltipErrorMessage" ><p>$Text{"This field is required."}</p></div>
<div id="RichTextServerError" class="TooltipErrorMessage NoJavaScriptMessage$QData{"BodyInvalid"}" ><p>$Text{"This field is required."}</p></div>
<div class="Clear"></div>
</div>
<div>
<label for="Attachment">$Text{"Attachment"}:</label>
<input name="file_upload" id="Attachment" title="Attachment" type="file" size="40" />
<input type="hidden" id="AttachmentUpload" name="AttachmentUpload" value="0" />
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
$('#Attachment').bind('change', function (Event) {
var $Form = $('#Attachment').closest('form');
Core.Form.Validate.DisableValidation($Form);
$Form.find('#AttachmentUpload').val('1').end().submit();
});
//]]></script>
<!--dtl:js_on_document_complete-->
<!-- dtl:block:Attachment -->
<div class="Attachment">
$QData{"Filename"} <span>$QData{"Filesize"}</span>
<button type="submit" name="AttachmentDelete$QData{"FileID"}" value="$Text{"Delete"}">$Text{"Delete"}</button>
</div>
<!-- dtl:block:Attachment -->
<div class="Clear"></div>
</div>
<!-- dtl:block:Priority -->
<div>
<label for="PriorityID">$Text{"Priority"}:</label>
$Data{"PriorityStrg"}
<div class="Clear"></div>
</div>
<!-- dtl:block:Priority -->
<!-- dtl:block:FreeText -->
<div>
$Data{"TicketFreeKeyField"}
<div class="Field">
$Data{"TicketFreeTextField"}
</div>
<div id="TicketFreeText$Data{"Count"}UsedError" class="TooltipErrorMessage NoJavaScriptMessage$QData{"ServerError"}"><p>$Text{"This field is required."}</p></div>
<div class="Clear"></div>
</div>
<!-- dtl:block:FreeText -->
<!-- dtl:block:FreeTime -->
<div>
$Data{"TicketFreeTimeKey"}
$Data{"TicketFreeTime"}
<div id="TicketFreeTime$Data{"Count"}UsedError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div>
<div class="Clear"></div>
</div>
<!-- dtl:block:FreeTime -->
<!-- dtl:block:ArticleFreeText -->
$Data{"ArticleFreeKeyField"}
$Data{"ArticleFreeTextField"}
<div id="ArticleFreeText$Data{"Count"}UsedError" class="TooltipErrorMessage NoJavaScriptMessage$QData{"ServerError"}"><p>$Text{"This field is required."}</p></div>
<div class="Clear"></div>
<!-- dtl:block:ArticleFreeText -->
<div id="BottomActionRow" class="ActionRow">
<button id="submitRichText" accesskey="g" title="$Text{"Submit"} (g)" type="submit" value="$Text{"Submit"}">$Text{"Submit"}</button>
</div>
</fieldset>
</form>
</div>
</div>
<!-- dtl:js_on_document_complete -->
<script type="text/javascript">
Core.Customer.InitFocus();
switch ($('#TypeId').val() ) {
case "1\|\|Default":
document.getElementById('Dest').value = '2\|\|Raw';
break;
case "2\|\|RfC":
document.getElementById('Dest').value = '2\|\|Raw';
break;
case "16\|\|Richiesta::Collegamento":
document.getElementById('Dest').value = '5\|\|DGSA-Collegamenti';
break;
case "17\|\|Richiesta::InterventoCentrali":
document.getElementById('Dest').value = '6\|\|DGSA-InterventiCentrali';
break;
case "18\|\|Richiesta::InterventoIntermedi":
document.getElementById('Dest').value = '7\|\|DGSA-InterventiIntermedi';
break;
default:
document.getElementById('Dest').value = '2\|\|Raw';
}
</script>
<!-- dtl:js_on_document_complete -->
moderator edit: added code tag -- crythias