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.

background script to close all incidents.

akshayjain
Tera Expert

What should I write in background script to close all incidents or delete all incidents

6 REPLIES 6

ARG645
Tera Guru
closeStaleIncidents();
function closeStaleIncidents() {
    var closeState = 7;
    var gr = new GlideRecord('incident');
    gr.query(); 
    gr.setValue('state', closeState);
    gr.updateMultiple();
    //Use gr.deleteMultiple(); to delete all Incidents
}

Reference: 

Pro Tip: Use updateMultiple() for Maximum Efficiency! by Tim Woodruff

sachin_namjoshi
Kilo Patron
Kilo Patron

Hi Akshay,

 

Please mark my answer as correct so that others can benefit from similar question.

 

Regards,

Sachin