Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

SLA cancellation through fix script for bulk 300+ incidents

phr
Tera Contributor

Hi All,

 

I have a requirement asking to cancel the SLA through fix script for 300+ incidents. There are 2 to 3 SLA's associated with each incident.

 

Do we have any fix script to cancel the associated sla's for 300+ incidents.

 

I have created the below fix script :

var gr = new GlideRecord("task_sla");
gr.addQuery("sys_id", "147b31d1fb97025418d6fca0aeefdcb9");
gr.query();
if (gr.next()) {
gr.setValue('stage',"cancelled");
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}

 

which is time consuming as he requirement is to  cancel the sla's associated with 300+ incidents.

How to achieve this?

2 ACCEPTED SOLUTIONS

ersureshbe
Giga Sage
Giga Sage

Hi, First you need filter those 300 tickets. I recommend to go 'Task_SLA' table and add the filter condition. Filter those 300 tickets and use 'Copy Query' and use that condition in 

gr.addEncodedQuery('ADD TASK_SLA' table filter condition) i.e., your code 2nd line will be replaced by what I mentioned above.

Regards,
Suresh.

View solution in original post

Musab Rasheed
Tera Sage

Hello,

Few years back I have done similar requirement, I had cancelled few thousand records, it will not take much time, you can directly insert incident number in query and simply run the script.

var gr = new GlideRecord("task_sla");
gr.addQuery("numberININC1234,INC3333,INC4555,INC3443");
gr.addQuery('state', 'NOT IN', 'completed,cancelled');
gr.query();
while(gr.next()) {
gr.setValue('stage',"cancelled");
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}

 

Please hit like and mark my response as correct if that helps
Regards,
Musab

View solution in original post

2 REPLIES 2

ersureshbe
Giga Sage
Giga Sage

Hi, First you need filter those 300 tickets. I recommend to go 'Task_SLA' table and add the filter condition. Filter those 300 tickets and use 'Copy Query' and use that condition in 

gr.addEncodedQuery('ADD TASK_SLA' table filter condition) i.e., your code 2nd line will be replaced by what I mentioned above.

Regards,
Suresh.

Musab Rasheed
Tera Sage

Hello,

Few years back I have done similar requirement, I had cancelled few thousand records, it will not take much time, you can directly insert incident number in query and simply run the script.

var gr = new GlideRecord("task_sla");
gr.addQuery("numberININC1234,INC3333,INC4555,INC3443");
gr.addQuery('state', 'NOT IN', 'completed,cancelled');
gr.query();
while(gr.next()) {
gr.setValue('stage',"cancelled");
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}

 

Please hit like and mark my response as correct if that helps
Regards,
Musab