Auto close resolved incidents business rule and scheduled item is not working as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 11:42 PM
We have defined business rule, scheduled item, and system property to auto close the particular resolved incidents, but not closing the incidents and not getting any logs in system logs. can someone please help on it. here am pasting BR, schedueld item, and system property. for testing purpose we can not wait for days. is there any way that we can set some minutes.
after BR:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
autoCloseIncidents();
function autoCloseIncidents() {
var ps = gs.getProperty('glide.ui.securityincidentautoclose.time');
var pn = parseInt(ps);
var queryTime = new GlideDateTime();
queryTime.addDaysUTC(-pn);
//queryTime.addSeconds(-pn);
if (pn > 0) {
var gr = new GlideRecord('incident');
gr.addEncodedQuery('category=IT Security^u_security_incident_stateNOT INproposed,accepted,rejected^incident_state=6');
// gr.addQuery('sys_updated_on', '<', queryTime);
gr.addQuery('sys_updated_on', '<', queryTime);
gr.query();
while(gr.next()) {
gr.state = 7;
gr.setLimit(3);
gr.comments = 'Incident automatically closed after ' + pn + ' days in the Resolved state.';
gr.active = false;
gr.work_notes="Auto closed resolved incidents through Business rule";
gr.closed_by = gr.resolved_by;
gs.log("The resolved incidents are closed");
gr.update();
}
}
}
});
scheduled item:
System Property:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2022 04:54 AM