Clarity Service Management

Expand all | Collapse all

Clear Category (Incident Area) When Updating Ticket Type

Jump to Best Answer
  • 1.  Clear Category (Incident Area) When Updating Ticket Type

    Posted 10-16-2015 11:36 AM

    We have added an activity type to update a ticket to a Request (from an Incident) and an Incident (from a request).  This question is 2 part.

     

    1. I have added the CR Category to the form but I'd like to clear out that field so the user has to choose a new Category any time they update the ticket type.  This, obviously, is because the Incident Areas and Request Areas can be different.

     

    2. Is there a way to default or remove the option in the "Ticket Type" dropdown to only show the opposite type that the ticket already is?  For instance, when I add it now, since the ticket is already and Incident, both Incident and Request show in the dropdown and I'd only like it to show Request or at least default to Request.

     



  • 2.  Re: Clear Category (Incident Area) When Updating Ticket Type

    Posted 10-16-2015 03:35 PM

    this is not optimal but was the first thing that came to mind,

    it will be easy to implement if you familiar with js:

     

    1. add onchange event to your dropdown

            detailSetEventHandler("onchange='switchArea(this.value);'");

            detailDropdown("Ticket type", "type", "pri", 1, 20,

                true, "", "$args.type",

                "no", "type", "$args.type",

                "","","no","","",

                "$args.type.sym",

                "Request,"R",

                "Incident","I"

            );

    2. you need function to hide objects;

    3. add 2 fake area lookups (attr=n\a factory=pcat_cr) and (attr=n\a factory=pcat_in) with onchange function;

    4. add hidden input which will be set actual area: <input type=HIDDEN name=SET.category id=SET_AREA value="">

    6. create function which will update hidden input with value from fake lookup;

    7. create function which will be switch visibility of fake lookups due to current dropdown value (example could be found here : https://communities.ca.com/message/241820136#241820136);



  • 3.  Re: Clear Category (Incident Area) When Updating Ticket Type

    Posted 10-19-2015 10:32 AM

    So I updated the first part, to get the dropdown to work.  However, how do I get it to change to "Request" if the ticket type is already an Incident?  It keeps defaulting to Incident. Do I need to create a "switchArea" function?  If so, what would this need to look like?  Right now it's functioning the same way as if I did it through the PDM_MACRO and filtered out Problem.

     

    detailSetEventHandler("onchange='switchArea(this.value);'");

    detailDropdown("Ticket Type", "type", "pri", 1, 20,true, "", "$args.type", "no", "type", "$args.type","","","no","","", "$args.type.sym", "Request","R","Incident","I");



  • 4.  Re: Clear Category (Incident Area) When Updating Ticket Type

    Posted 10-19-2015 11:21 AM

    ok, i did it in my test env. looks ugly but works well...

    Replace "LOG" with your own ACTIVITY_TYPE and remember to place onloadSwitch() to body onload function.

    code:

     

    function switchArea(value) {
        var zlnks = ahdframe.document.getElementsByTagName('a');
        for(var i=0;i<zlnks.length;i++) {
            console.log(typeof(zlnks[i].onclick));
            if (typeof(zlnks[i].onclick) == "function") {
                if (zlnks[i].onclick.toString().indexOf('popup_hier')>0) {
                    console.log(value);
                    if (value == "I")
                        zlnks[i].onclick = function (){popup_hier('pcat_in','KEY.category','main_form','sym',1);};
                    else
                        zlnks[i].onclick = function (){popup_hier('pcat_cr','KEY.category','main_form','sym',1);};
                }
            }
        }
    }
    function onloadSwitch() {
        <PDM_IF "$args.ACTIVITY_LOG_TYPE" == "LOG">
        switchArea('$args.type');
        </PDM_IF>
    }
    <PDM_IF "$args.ACTIVITY_LOG_TYPE" == "LOG">
        <PDM_MACRO name=dtlStartRow>
        detailSetEventHandler("onchange='switchArea(this.value);'");
        detailDropdown("Ticket Type", "type", "pri", 1, 20,true, "", "$args.type", "no", "type", "$args.type","","","no","","", "$args.type.sym", "Request", "R", "Incident", "I");
        <PDM_MACRO name=dtlHier hdr="Ticket Area" attr=category autofill=no make_required=yes>
    </PDM_IF>
    
    


  • 5.  Re: Clear Category (Incident Area) When Updating Ticket Type

    Posted 10-19-2015 11:43 AM

    Once again this is very helpful.  But one of the main things I'm trying to accomplish is that if you open up the activity to update the ticket type, it will automatically set the Ticket Type dropdown to the opposite of what it currently is.  Your code does the rest for the category, but I didn't know if there was a way to update that ticket type field on load to "Request" if the ticket was already an incident.



  • 6.  Re: Clear Category (Incident Area) When Updating Ticket Type
    Best Answer

    Posted 10-19-2015 03:42 PM

    sorry, didnt catch that, simply remove defaul value from dropdown code:

    detailDropdown("Ticket Type", "type", "pri", 1, 20,true, "", "$args.type", "no", "type", "$args.type","","","no","","", "", "Request", "R", "Incident", "I");


    edited: one more miss :)

    previos entry for empty default,

    here is to opposite:

    var ttype = "I";
    if ("$args.type" == "I") ttype = "R";
    
    detailDropdown("Ticket Type", "type", "pri", 1, 20,true, "", "$args.type", "no", "type", "$args.type","","","no","","", ttype, "Request", "R", "Incident", "I");
    


  • 7.  Re: Clear Category (Incident Area) When Updating Ticket Type

    Posted 10-04-2016 11:15 PM

    @KennethHosey

    We have the same requirement.  Would you post you final form for us? 

     

    I started with a copy of request_status_change as a template and have updated it using the methods that you and cdtj have shown, but the category field doesn't clear on change of the type dropdown.  The switchArea function does work when the lookup link is selected.  However, none of the values are saved to the ticket when Accepted.  I did include the tabReloadOnSave as shown in Forcing Refresh of Ticket on Return from Custom Activity .

     

    Thanks,

     

    J.W.



  • 8.  Re: Clear Category (Incident Area) When Updating Ticket Type

    Posted 10-05-2016 11:31 AM

    Update:

    The values do save to the ticket - it changes to the correct type and the category is updated. 

     

    The dtlHier macro doesn't take a value parameter so I'm curious how you were able to clear the field either on form load or when the value in the type dropdown is changed.

     

    Alternatively, I guess I can try my hand at not clearing it and instead do a validation check on save and make sure that the cr_flag or in_flag is set based on the value of the type field.

     

    Any suggestions would be appreciated.

     

    J.W.