Disable UI Action

aamir khan
Tera Contributor
Dear Members, 
 
We have OnClick UI action on Incident record & below is the script which return the Ticket to Helpdesk group whenever required and then helpdesk agent transfer the ticket to other group.
 
We need to limit this UI Action in such a way that if the the ticket already returned 5 times to Helpdesk group. This UI Action should be freeze or disappear from the ticket so the ticket cannot be return anymore. 
 
Please advise in the script what to add to achieve this case. 
 
Script:
 
function ReturnToHelpdesk() {
    if (g_form.getValue("work_notes") == "") {
        g_form.setMandatory("work_notes", true);
        g_form.clearMessages();
g_form.setValue('state',1);
        getMessage("Work Note", function(msg) {
            g_form.addErrorMessage(msg, "error");
        });
    }
    gsftSubmit(null, g_form.getFormElement(), 'Return_To_Help_Desk'); 
}
 
if (typeof window == 'undefined')
    Default();
 
function Default() {
    var GroupName = gs.getProperty('Help Desk');
    current.assignment_group = GroupName;
    current.update();
    action.setRedirectURL(current);
}
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@aamir khan 

you need to have a custom integer type field to store the count and then increment it from server side each time button is clicked

UI Action condition

Your Existing UI Action Condition && current.u_count <= 5

Script Update

function Default() {
    var GroupName = gs.getProperty('Help Desk');
    current.assignment_group = GroupName;
    current.u_count = current.u_count + 1;
    current.update();
    action.setRedirectURL(current);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

aamir khan
Tera Contributor

Hi All, 

 

Thanks for your solution. I have followed Ankur's suggestion which have fulfilled my need.

 

Many Thanks