- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 07:00 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 03:27 AM
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.
Suresh.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 04:58 AM
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();
}
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 03:27 AM
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.
Suresh.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 04:58 AM
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();
}
Regards,
Musab