SLA

Qunle
Tera Contributor

Old SLA's still running. How can i clean up/close out attached SLA's. These are incidents closed more than a year ago but has attached SLA's still running. This comes up in my report every time and displays inaccurate results.

Thank you

2 ACCEPTED SOLUTIONS

Harshal Aditya
Mega Sage
Mega Sage

Hi @Qunle ,

 

Hope you are doing well.

 

In that case I would suggest you to bulk close the SLA records using a fix/background script

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

View solution in original post

SANDEEP28
Mega Sage

@Qunle  If incidents are already closed then you can query Task SLA table and change the status of these SLA record to Cancelled using background script. 

 

First thing you need to build query of SLA record which needs to be closed in list of Task SLA table.

 

SANDEEP28_1-1690392427877.png

 

Put the date range from when to when you want to close those SLA record. Copy the query and use in below background script. First test with few records in development instance then execute in production.

 

var grTaskSla = GlideRecord('task_sla');
grTaskSla.addEncodedQuery('task.numberSTARTSWITHINC^task.active=true^task.sys_created_onBETWEENjavascript:gs.dateGenerate('2023-06-01','00:00:00')@javascript:gs.dateGenerate('2023-07-25','23:59:59')^stageINin_progress,paused');
grTaskSla.query();
while (grTaskSla.next())
{
if (grTaskSla.getElement('task.state') == 7)
{ // check if incident status is closed
grTaskSla.setValue('stage', 'cancelled');    // Mark sla status as cancellled
grTaskSla.update();
}
}

  If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !! 

 

 

 

View solution in original post

2 REPLIES 2

Harshal Aditya
Mega Sage
Mega Sage

Hi @Qunle ,

 

Hope you are doing well.

 

In that case I would suggest you to bulk close the SLA records using a fix/background script

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

SANDEEP28
Mega Sage

@Qunle  If incidents are already closed then you can query Task SLA table and change the status of these SLA record to Cancelled using background script. 

 

First thing you need to build query of SLA record which needs to be closed in list of Task SLA table.

 

SANDEEP28_1-1690392427877.png

 

Put the date range from when to when you want to close those SLA record. Copy the query and use in below background script. First test with few records in development instance then execute in production.

 

var grTaskSla = GlideRecord('task_sla');
grTaskSla.addEncodedQuery('task.numberSTARTSWITHINC^task.active=true^task.sys_created_onBETWEENjavascript:gs.dateGenerate('2023-06-01','00:00:00')@javascript:gs.dateGenerate('2023-07-25','23:59:59')^stageINin_progress,paused');
grTaskSla.query();
while (grTaskSla.next())
{
if (grTaskSla.getElement('task.state') == 7)
{ // check if incident status is closed
grTaskSla.setValue('stage', 'cancelled');    // Mark sla status as cancellled
grTaskSla.update();
}
}

  If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!