Any ideas on how to script on mass repair SLA's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2016 06:03 AM
Hi Guys ,
I got a requirement to design a script for mass repair of SLA's ? i couldn't find anything regarding that .. could you help me with any lead ?
Thanks in advance ,
Sanjay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2017 06:25 PM
Thanks. Would you be able to help me with the script?
Regards,
Robin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 12:58 PM
Robin,
I don't use the 'Repair SLA' frequently so I wasn't aware of this but ServiceNow has a UI Action (Repair all filtered SLAs) that should help you.
- Go to task_sla.list and then filter the list to only the SLA's that you want to repair
- Scroll to the bottom of your list and you should see the UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2017 09:38 AM
Hi Jacob,
Unfortunately the UI Action can only be run against a list of records, so it's limited to 1000 at a time (I have 13k+ to update so would take a while). I was hoping to find a way to bulk update from a Glide Query.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2016 10:57 AM
Alekhya,
The SLA Repair runs against records in the task_sla table.
So I would need to know more about what about your SLAs are triggering the need to run repair.
If you can use a date field on the form then I would do that.
You can do 'created' in last 24 hours, 'breach time' in last 24 hours, or whatever is triggering the repair need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2017 09:54 PM
Hi Sanjay,
I had exactly the same question and I worked it out. (I am on Istanbul)
1. Go to System Definition > Script Includes and search for RepairSLA. This is a very useful class to help script what you are doing. Keep that handy to refer to while making your script
2. Create a new Fix script that uses this include. Below is one that i wrote,
- you should change the query with one that you want and that should be the only change.
- On my system it took a few minutes to update about 1k records.
- This is my first script so i'm sure its got problems. But its a start.
var gr = new GlideRecord('incident');
gr.addQuery("numberSTARTSWITHMINC_");
gr.query();
gs.info("Number of incidents to update " + gr.getRowCount());
var sla = new SLARepair();
while(gr.next()){
var sysId = gr.getValue('sys_id');
gs.info("Updating incident " + sysId);
sla.repairBySysId(sysId, "incident");
}
3. Run in the background
4. Open Service Level management > repair Logs > All repairs and you can see the repair items as they are executed