Is there a way to bypass the conditions in SLA?

jeansky
Tera Contributor

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?

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

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.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

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]

****************************************************************************************************************

shloke04
Kilo Patron

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.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

piyushsain
Tera Guru
Tera Guru

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)

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain