How to supress notification on Incident

Akshaykhare
Tera Contributor

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.

 

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();


}
 
In this script I am using the line gr.setWorkflow(false) which supress the notification but due to this line SLA is not getting cancled and if I comment out this line SLA is getting cancelled but notification are also getting triggered
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Akshaykhare 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

@Akshaykhare 

can you share what do you mean by SLA timer is still running? share screenshot

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

SNOW.png

I am reffering to actual elapsed time and business elapsed time as highlighted in image. These times are still running.

@Akshaykhare 

are they getting refreshed? did you reload and see if the value got updated

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 
Yes I can confirm, they are getting updated, as I am continuously monitoring and reloading them.

@Akshaykhare 

In my case the time has stopped and it doesn't refresh.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader