How to stop SLA without removing setworkflow in BG script

thaduri sai
Tera Contributor

Hi Team,

We have a requirement to close bulk incidents through background script.

 

Script:-

var gr = new GlideRecord('incident');

gr.addQuery('your_criteria_field', 'your_criteria_value');

gr.query();

 

while (gr.next()) {

    gr.setValue('incident_state', '7');

    gr.setValue('close_code', 'your_close_code');

    gr.setValue('close_notes', 'Your closing notes');

    gr.setWorkflow(false);

    gr.update();

}

 

By using this above script. we are able to close the incidents. But still SLA is running. How to stop SLA without removing setworkflow(false).

 

Kindly please help on this.

 

Thanks for the advance.

 

Thanks,

Saikrishna

 

5 REPLIES 5

Ahmmed Ali
Mega Sage

Hello @thaduri sai 

 

You can repair SLA using the UI action in incident list. Open incident list > filter the list > select all > action > Repair SLA.

 

Below thread explains about repair SLA through fix script: https://www.servicenow.com/community/developer-forum/repair-sla-via-fix-script/m-p/1843836 

 

Thank you,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali