Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI action not working in Security Incident Response Workspace

mpmacconnell
Tera Guru

We have a custom UI action that is not working in the Security Incident Response workspace. It works fine in the new UI. Need some help on figuring out why. I have converted some of the alerts to use the g_modal method, but the script does not run that queries the records and updates them.

 

Here is the script (the g_modal is not included here as I am playing with that in another instance):

function onClick(g_form)
{
var answer = confirm("This will close all the active child Security Incidents associated with this Incident. Please click OK to confirm.");
    //alert(answer);
    if (answer == true)
    {
        gsftSubmit(null, g_form.getFormElement(), 'closeChildrenSI');
       
    }
    else
    {
        return;
    }
}

if (typeof window == 'undefined')
{
    closeChildrenIncidents();
}


function closeChildrenIncidents()
{

        var childSIR = new GlideRecord("sn_si_incident");
        //childSIR.addEncodedQuery("state!=100^active=true^parent_security_incident="+current.sys_id);
        childSIR.addEncodedQuery("active=true^parent_security_incident="+current.sys_id);
        //childSIR.setLimit(2);
        childSIR.query();
        var totalActChild = childSIR.getRowCount();
        var closedActChild = 0;
       
        while(childSIR.next())
        {
            var hasTasks = new global.SMTask().hasOpenTasks(childSIR);

            //gs.addInfoMessage(hasTasks);

            if(hasTasks != true)
            {
                //gs.addInfoMessage("In if : " + hasTasks);
                childSIR.state = 3;
                childSIR.close_notes = "Resolve or Close Notes - Children ticket closed and any further actions will be captured on parent ticket, "+current.number;
                childSIR.u_incident_categorization = current.u_incident_categorization;
                childSIR.u_sir_function_imp = current.u_sir_function_imp;
                childSIR.u_sir_info_impact = current.u_sir_info_impact;
                childSIR.business_criticality = current.business_criticality;
                childSIR.u_sir_recoverability = current.u_sir_recoverability;
                childSIR.u_actual_sir_list = current.u_actual_sir_list;
                childSIR.contact_type = current.contact_type;
                childSIR.close_code = current.close_code;
                childSIR.u_event_type = current.u_event_type;
                childSIR.update();
                closedActChild += 1;
            }
        }
        action.setRedirectURL(current);
        gs.addInfoMessage(closedActChild + " child incidents "+ " out of "+ totalActChild + " active child incidents closed");

        var missedChild = parseInt(totalActChild)-parseInt(closedActChild);

        if(missedChild > 0)
        {
            gs.addInfoMessage(missedChild + " incidetns were not closed as they have active Response Tasks");
        }
       
}
2 REPLIES 2

Abbas_5
Tera Sage
Tera Sage

Hello @mpmacconnell,

Please check out the link below:
https://www.servicenow.com/community/developer-forum/why-ui-action-is-not-working-in-service-operati...

 


If it is helpful, please mark it as helpful and accept the correct solution. In future, it might be helpful for someone to refer to this solution.
Thanks & Regards,

Abbas Shaik

mpmacconnell
Tera Guru

Turns out it was the line:

gsftSubmit(null, g_form.getFormElement(), 'closeChildrenSI');

 

I had to change that line and got it working using the g_form method.