Closed by the system Incidents are not completing their SLA records correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 01:01 PM
Hello guys,
I am having a hard time figuring out what's wrong with my SLA stop condition as it stuck in paused stage and not move into 'Completed' Stage when the incident is auto closed by the system. But when I manually close the Incident, then it completes the SLA record correctly, every time.
Here is my Stop Condition, the SLA should Stop after the Incident is Closed.
Here is my paused condition
Below is also my Auto Close Incident BR.
// This script automatically closes incidents that are resolved
// and haven't been updated in the specified number of days.
// This number is a property in System Properties.
// To place a comment in the incident, uncomment the "gr.comments" line.
autoCloseIncidents();
function autoCloseIncidents() {
var ps = gs.getProperty('glide.ui.autoclose.time');
var pn = parseInt(ps);
var queryTime = new GlideDateTime();
queryTime.addDaysUTC(-pn);
if (pn > 0) {
var gr = new GlideRecord('incident');
gr.addQuery('incident_state', IncidentState.RESOLVED);
if (gs.getProperty('com.snc.incident.autoclose.basedon.resolved_at', 'false') === 'true') {
gr.addQuery('resolved_at', '<', queryTime);
}
else {
gr.addQuery('sys_updated_on', '<', queryTime);
}
if (pm.isActive('com.snc.incident.mim')) {
var mim = gr.addNullQuery('major_incident_state');
mim.addOrCondition('major_incident_state', '!=', new sn_major_inc_mgmt.MajorIncidentTriggerRulesSNC().MAJOR_INCIDENT_STATE.ACCEPTED);
}
gr.query();
while(gr.next()) {
gr.incident_state = IncidentState.CLOSED;
gr.setValue('state', 7);
// gr.comments = 'Incident automatically closed after ' + pn + ' days in the Resolved state.';
gr.active = false;
gr.closed_by = gr.resolved_by;
gr.closed_at = gs.nowDateTime();
gr.update();
}
}
}
Please assist on what I need to be done to get the SLA set to completed when the incident state auto closed by the system.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 01:06 PM
Hello,
Your images are not showing, please embed then using the "Insert Image" button within the reply window.
Additionally, please use the "Insert/Edit code sample" button when pasting code so that it remains organized and easier to read.
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 04:28 AM
Thank You Allen for pointing this out. Below are the new SLA pictures and the code. I really appreciate your assistance on this.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 04:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 04:23 AM