using ui action we need to create a button state to move closed

BheemavarapuTej
Tera Expert

Using UI actions, we must create a button state to move to the closed list level. Once I select the record, it should be updated to close.

2 REPLIES 2

Gangadhar Ravi
Giga Sage
Giga Sage

You can follow this docs 

https://docs.servicenow.com/bundle/xanadu-it-service-management/page/product/incident-management/tas...

OR

you can do a simple UI action like below image 

GangadharRavi_0-1726324685223.png

Please mark my answer correct and helpful if this works for you.

 

BheemavarapuTej
Tera Expert

It looks like you've written, "This code didn't work. I wrote a new code, and it's working correctly now."

 

 

function actionOK() {
    var sysId = g_list.getChecked();
    var inc = new GlideAjax('IncidentClosure');
    inc.addParam('sysparm_name', 'closeIncidents');
    inc.addParam('sysparm_incidents', sysId);
    inc.getXML(serverData);

    function serverData(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if (answer === 'true') {
            alert("short_description changes");
        } else {
            alert("Failed to close incidents");
        }
    }
}


var IncidentClosure = Class.create();
IncidentClosure.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    closeIncidents: function() {
        var selectedIncidents = this.getParameter("sysparm_incidents");
        var incidentGr = new GlideRecord('incident');
        incidentGr.addQuery('sys_id', 'IN', selectedIncidents);
        incidentGr.query();
        while (incidentGr.next()) {
            incidentGr.setWorkflow(false);
            incidentGr.setValue('short_description','test');
            incidentGr.setValue('state',2);
           
            incidentGr.update();
        }
        return true;
    },
   
    type: 'IncidentClosure'
});