Queue Change based upon type

Moderator: crythias

Locked
StefanoBoccanera
Znuny newbie
Posts: 76
Joined: 23 Feb 2011, 15:43
Znuny Version: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Queue Change based upon type

Post by StefanoBoccanera »

crythias 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:

Code: Select all

    switch ($('#TypeID').val() ) {
    case "1":
        document.getElementById('Dest').value = '3\|\|Junk';
    break;
    default:
    }
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?

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.
Hi crythias

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
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To show freetext for specific Queues for Customers

Post by crythias »

It won't work because you're using "Queue" cases for TypeIds.

TypeId is an integer. Queues are number\|\|name.

In case that wasn't clear enough:
switch is asking the question: "I have the value of TypeId?"

case is saying, "is it 1\|\|Default?" then set the Queue (Dest) to '2\|\|Raw'.

But TypeId is going to be '1', so the case should be:
case "1":
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
StefanoBoccanera
Znuny newbie
Posts: 76
Joined: 23 Feb 2011, 15:43
Znuny Version: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: How To show freetext for specific Queues for Customers

Post by StefanoBoccanera »

crythias wrote:It won't work because you're using "Queue" cases for TypeIds.

TypeId is an integer. Queues are number\|\|name.

In case that wasn't clear enough:
switch is asking the question: "I have the value of TypeId?"

case is saying, "is it 1\|\|Default?" then set the Queue (Dest) to '2\|\|Raw'.

But TypeId is going to be '1', so the case should be:
case "1":
Hi crythias

You are right (by the way how I can get furhter information on document structure used by jscript?).
I modified the case statements but the form doens't work.

Let me decsribe what happen on form open:

a) The Ticket Type box doesn't have any ticket type selected (no default, but the customer has to select a type)
b) The queue box get the value of default case line
c) the focus pointer is on the text box of subject field

If I change the ticket type, after a brief screen refresh the value on queue field it's set to the default value.

I'm wondering if the problem is following code block:

-----------------------------------------------------------------------------------------------------------------------
<!-- 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 -->


---------------------------------------------------------------------------------------------

Can I disable the queue input, leaving the set to the case flow ?

regrads

stefano
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres
Locked