Running a fix script to update the stop time to be the resolve time of an incident and then resolve the SLA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 12:31 AM
I'm trying to create a fix script that will search for incidents created at a certain time where their task SLAs have been breached, take the Resolve time from each incident and update this in the Close time on any associated SLAs, and then repair the associated SLAs of each incident. I've written the below fix script and was just wondering if this would cover the scenario:
var tab = new GlideRecord('task_sla');
//Searches for the affected incident SLAs
tab.addEncodedQuery('task.sys_created_onONThis year@javascript:gs.beginningOfThisYear()@javascript:gs.endOfThisYear()^task.ref_incident.caller_idSAMEAStask.ref_incident.resolved_by^task.ref_incident.resolved_atBETWEENjavascript:gs.dateGenerate('2022-02-03','18:00:00')@javascript:gs.dateGenerate('2022-02-09','18:30:00')^has_breached=true');
//Runs the query
tab.query();
//Helps in prevent running of BR's while updating
tab.setWorkflow(false);
//While it's looping through the records
while(tab.next()){
//Sets the 'Stop time' field to match the resolved field in the related incident
end_time = task.ref_incident.resolved_at;
//Makes the update
tab.update();
}
var repair = new SLARepair();
while (now_GR.next())
repair.repairByGlideRecord(tab);
If there is anything that needs changing or if there's a better way of doing this, please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 05:32 AM
What I noticed when running the script is that it deletes the current task SLA entry and ten creates another one using historic data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 03:24 AM
Hi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 06:30 AM
Hi Matthew,
I would say probably a new business rule or script include.
At this point, is the requirement just to populate the stop time field on the newly inserted Task SLA record after it was repaired? Are you okay with how the script is initially setting the stop time in the field and then reparing the SLA? have you confirmed that the new SLA Task created has the data you would expect apart from the missing value for Stop time?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 06:51 AM
Hi Dan,
So the requirement is that on the current SLA tasks, they get their Stop Date updated to match the Resolved Date of the related incident. Then the idea is that when the Fix SLA part of the script is run, that would create the new SLA task entry with the Stop Date matching the new Resolved Date rather than reverting to the date and time the incident was originally closed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 06:54 AM
Hi