- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 09:56 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:27 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:30 AM
@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.
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 !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:27 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:30 AM
@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.
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 !!