- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2016 07:47 AM
Hello,
My high priority incidents that have been resolved are supposed to auto-close after a certain amount of time, but they are remaining in a state of 'Resolved'.
I am familiar with the system properties page that autocloses incidents as well as the auto-close business rule, however the OOB script purposely does not query as I have copied : gr.addQuery('priority','NOT IN','1,2'); I need my higher-priority resolved incidents to auto-close at a different time from the lower priority incidents. This is only dealing with resolved incidents overall.
Thanks in advance ,
Cliff
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2017 06:11 AM
Hi,
Try the following solution:
Create a new system property for the high priority incidents and put the value of the system property on "Days" not "Hours".
Create a new business with the same script as the OOB BR and just put the name of your newly created system property.
Edit the old BR whith a condition on the priority of the incident
Now create a new "Schedule Item" similar to the OOB "Autoclose Incidents" containing the name of your new BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2016 08:54 AM
Hi Cliff, which version are you on right now?
The Incident state model changed recently with Helsinki I believe.
We still use the values state but from now on we're using state values that makes sense like "Resolved" or "Closed"
On a technical note, the new state model is supported by a few Script Includes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2016 09:05 AM
Thank you for the info Stefan. I am running Geneva right now, although we are going to be moving to Helsinki in the first quarter of '17. Resolved and Closed is what values I am working with in this question, but good to hear
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2016 09:21 AM
If you could share your script I'd take a stab at it!
Also, if you're an admin, type scripts into the Filter Navigator to test your scripts real quick!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2016 09:25 AM
I am early into the script, and left out some logic I was not sure on (not a conventional approach I know. Im an admin, thank you for the tip.
// automatically close P1/P2 incidents that are resolved
// fpr 14 days or more.
//var ps = gs.getProperty('glide.ui.autoclose.time');
var limit;
if(limit > 125 ){
//Get a schedule by name to calculate duration
var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('name', '8-5 weekdays excluding holidays');
if (typeof GlideSchedule != 'undefined')
var sched = new GlideSchedule(schedRec.sys_id);
else
var sched = new Packages.com.glide.schedules.Schedule(schedRec.sys_id);
//Get the current date/time in correct format for duration calculation
var actualDateTime = new GlideDateTime();
actualDateTime.setDisplayValue(gs.nowDateTime());
//Query for resolved incident records
var gr = new GlideRecord('incident');
gr.addQuery('state', 6);
gr.addQuery('priority','1,2');
gr.query();
gr.setLimit(10);
while(gr.next()){
gr.state = 7;
gr.active = false;
gr.comments = 'Incident automatically closed after ' + limit + ' hours in the Resolved state.';
gr.update();
}
}