- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 11:42 PM
I want to cancel the incident in bulk but notification should not trigger to the assignment group for this process. I am using following script to cancel the INC.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2025 12:00 AM
set it cancel via script
var gr = new GlideRecord('incident');
gr.addEncodedQuery("numberININC0535119");
gr.query();
while(gr.next()) {
gr.state = '8';
gr.assignment_group = "874500c8db99af001ce298f3db9619e3";
gr.assigned_to = "12665d45dbacd300ebd7f3361d9619fe";
gr.business_service = "ef19a128dba86b003700ff361d961966";
gr.work_notes = "Canceling the change as per ----------";
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
// Manually stop SLAs
var slaGR = new GlideRecord('task_sla');
slaGR.addQuery('task', gr.sys_id);
slaGR.query();
while (slaGR.next()) {
slaGR.setValue('stage', 'cancelled'); // cancel SLA
slaGR.update();
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2025 12:00 AM
set it cancel via script
var gr = new GlideRecord('incident');
gr.addEncodedQuery("numberININC0535119");
gr.query();
while(gr.next()) {
gr.state = '8';
gr.assignment_group = "874500c8db99af001ce298f3db9619e3";
gr.assigned_to = "12665d45dbacd300ebd7f3361d9619fe";
gr.business_service = "ef19a128dba86b003700ff361d961966";
gr.work_notes = "Canceling the change as per ----------";
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
// Manually stop SLAs
var slaGR = new GlideRecord('task_sla');
slaGR.addQuery('task', gr.sys_id);
slaGR.query();
while (slaGR.next()) {
slaGR.setValue('stage', 'cancelled'); // cancel SLA
slaGR.update();
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2025 01:05 AM
@Ankur Bawiskar : This solution is setting the stage of SLA to cancelled but SLA clock is still running. Any solution for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2025 01:19 AM
are you saying the sla timer is still running?
try to set the stop time field (end_time) with the current date/time and see
var slaGR = new GlideRecord('task_sla');
slaGR.addQuery('task', gr.sys_id);
slaGR.query();
while (slaGR.next()) {
slaGR.setValue('stage', 'cancelled'); // cancel SLA
slaGR.setValue('end_time', new GlideDateTime());
slaGR.update();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2025 01:31 AM
@Ankur Bawiskar : I tried doing the same but again stop time(end_time) got mapped with the current date and time but SLA timer is still running.
SLA timer is getting stopped only when I don't use the line gr.setWorkflow(false) but then it triggers notification as well.