- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 03:01 AM
Hello,
I have a scenario in which we need to mass-close the incident tickets. These incident tickets have SLAs attached to them and we also need to force them to stop (because they are In Progress). However, the problem is that we cannot meet the stop condition of the SLA. Is there a way to mark the SLA stage as complete and stop the timer?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 03:17 AM
Hi @jeansky ,
Use the below background script to achieve this:
var gr = new GlideRecord('incident');
//gr.addEncodedQuery('Add your query here');
gr.query();
while(gr.next()){
gr.state=7;
closeSLA(gr);
gr.update();
}
function closeSLA(gr){
var taskSLA = new GlideRecord('task_sla');
taskSLA.addQuery('task',gr.sys_id);
taskSLA.query();
while(taskSLA.next()){
taskSLA.stage='completed';
taskSLA.end_time = new GlideDateTime();
taskSLA.update();
}
}
By default, Stop time attribute does not gets updated, so you can update it with current time stamp when you are marking the SLA stage as Completed.
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 03:07 AM
Hi @jeansky
I think, if you close the incident , then SLA also get stopped, if the condition met.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 03:17 AM
Hi @jeansky ,
Use the below background script to achieve this:
var gr = new GlideRecord('incident');
//gr.addEncodedQuery('Add your query here');
gr.query();
while(gr.next()){
gr.state=7;
closeSLA(gr);
gr.update();
}
function closeSLA(gr){
var taskSLA = new GlideRecord('task_sla');
taskSLA.addQuery('task',gr.sys_id);
taskSLA.query();
while(taskSLA.next()){
taskSLA.stage='completed';
taskSLA.end_time = new GlideDateTime();
taskSLA.update();
}
}
By default, Stop time attribute does not gets updated, so you can update it with current time stamp when you are marking the SLA stage as Completed.
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 03:23 AM
Hi @jeansky
You can mass close the incident and it will close the SLA itself, the only condition is that if you are doing it via script do not use setWorkflow(false)
Regards,
Piyush Sain