- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 06:11 AM
Hi experts,
We have 10-15 records for which SLA needs to be repaired. Can we do that manually or we need to do it using script.
If script, suggest me which script to be used.
TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 06:25 AM - edited 09-09-2024 08:10 AM
Hi @si21,
Based on the low number of 10-15 records, I would recommend manually executing the "SLA Repair" link on the SLA record so as to remain targeted and for you to test and confirm results before proceeding on others. This provides much more control - again, based on the low number of records.
Be sure to read the documentation and test in a lower environment on the SLA Repair job as found here:
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 06:22 AM
Hi @si21
To repair SLAs for specific records, you can either do it manually using the SLA Repair function available in the ServiceNow UI or use a script if you need to do it for multiple records in bulk.
Manual repair each record:
- Go to the record (such as an Incident or Request) where the SLA needs to be repaired.
- Right-click the form header, and click Repair SLAs.
- This will repair the SLA for the individual record by recalculating the SLA timers and conditions.
Bulk repair vai script:
// Array of sys_ids of records you want to repair SLAs for
var recordIds = [
'your_record_sys_id_1',
'your_record_sys_id_2',
'your_record_sys_id_3'
// Add more sys_ids here
];
// Table where the SLA applies (e.g., incident, sc_req_item, etc.)
var tableName = 'incident'; // Replace with your table (like 'sc_req_item' for RITMs)
// Iterate through each record and repair the SLAs
for (var i = 0; i < recordIds.length; i++) {
var gr = new GlideRecord(tableName);
if (gr.get(recordIds[i])) {
gs.log('Repairing SLA for record: ' + gr.number);
var slaRepair = new SLARepair();
slaRepair.repair(gr);
gs.log('SLA repaired for record: ' + gr.number);
} else {
gs.log('Record not found: ' + recordIds[i]);
}
}
i home my answer helps you to resolve your issue, if yes please mark my answer correct and helpful.
thank you
rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 07:49 AM
Hi @Rajesh Chopade1 , shall I use this is fix script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 07:53 AM
Hi
Yes, I have provided the script but as @Robbie suggested use manual way because you having less records to update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 06:25 AM - edited 09-09-2024 08:10 AM
Hi @si21,
Based on the low number of 10-15 records, I would recommend manually executing the "SLA Repair" link on the SLA record so as to remain targeted and for you to test and confirm results before proceeding on others. This provides much more control - again, based on the low number of records.
Be sure to read the documentation and test in a lower environment on the SLA Repair job as found here:
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie