Incident autoclose not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2016 01:08 PM
Hello SNC -
I need some help on understanding the Incident Autoclose process and how to fix it. It doesn't appear to be working in my environment, and I'm in need to some help resolving it.
1.) System Properties is set to 1:
2.) Business Rule is set to the following:
Advanced: (Script)
// 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.
function onAfter(current, previous) {
//This function will be automatically called when this rule is processed
}
autoCloseIncidents();
function autoCloseIncidents() {
var ps = gs.getProperty('glide.ui.autoclose.time');
var pn = parseInt(ps);
if (pn > 0) {
var gr = new GlideRecord('incident');
gr.addQuery('incident_state', '6');
gr.addQuery('sys_updated_on', '<', gs.daysAgoStart(pn));
gr.query();
while(gr.next()) {
gr.incident_state = '7';
// gr.comments = 'Incident automatically closed after ' + pn + ' days in the Resolved state.';
gr.active = false;
gr.update();
}
}
}
3.)Now for the scheduled script.
This is currently running in our environment: (Attachment - ScheduledJob.png)
4.)
This was setup prior me starting with my company by an outside vendor, so I'm picking up the pieces as I go so could really use your help.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2016 02:01 PM
Hi Chris,
Couple of things. Your tickets incident_state is 6 for resolved tickets (which you are expecting to auto-close) ? Also this Business Rule generally Runs in Global Domain , any specific reason why its domain is not global ? I guess that this Business Rule will only close the tickets which are in Top/Godiva domain.
I will suggest try changing BR domain to Global and see the result. Also verify the incident_state value.
Thanks,
Rajeev Lochan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2016 08:32 PM
Thanks for the advice. I changed the BR to "Global" and it processed correctly! Thank you so much!
Our parent company acquired our ServiceNow instance. We are setup as a Domain Separated instance. We were first to acquire ServiceNow a couple years ago, and they later joined the club.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2016 06:24 AM
Not sure if you still have this, but you should have this on "global". It's against Best practice and can cause performance issues.
"Note: To avoid potential performance issues, the Incident Autoclose business rule should be set on the Incident [incident] table, not the Global [global] table."
Can read more about it here in the documentation: Close resolved incidents automatically
//Göran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2016 02:47 PM
Hi Goran,
The article you mention is about what table you run your Business Rules on (run it on incident and not on Global).
But the suggestion from Rajeev was about changing the domain the business rules runs on (it's a domain separated instance they were using), not the table it runs on.
So i think the solution provided is not against the best practice you mention.
Marcus