- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 02:18 PM
Hey everyone,
It appears as though when Event Management was implemented at my company, the Alert Auto close interval property (evt_mgmt.alert_auto_close_interval) was changed from the out of the box value of 168 to 0 (thus disabling this feature). I was contemplating turning it back on, but had a quick question about its functionality.
The Docs site states that the value entered in this property specifies "The number of hours the system waits until it automatically closes an expired alert.". My question is what does ServiceNow consider to be an "expired alert"? Is this an Alert that has not been updated within the number of hours you specify in the property? Or is this the number of hours since the created date of the alert record that it will wait for until closing the alert automatically?
Solved! Go to Solution.
- Labels:
-
Event Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 02:42 PM
Dominic,
The scheduled job, 'Event Management - auto close alerts', handles this function. It's logic appears to be comparing, in seconds, the alert's last update time vs now.
var CLOSE_INTERVAL = GlideProperties.get('evt_mgmt.alert_auto_close_interval', 168);
if (parseInt(CLOSE_INTERVAL) > 0){
var alertGr = new GlideRecord("em_alert");
alertGr.addQuery("state","!=","Closed");
alertGr.query();
while(alertGr.next()){
var last_event = alertGr.getValue("sys_updated_on");
var last_eventGdt = new GlideDateTime(last_event);
var now = new GlideDateTime();
last_eventGdt.addSeconds(CLOSE_INTERVAL*3600);//1 hour = 3600 seconds
//it's time to close the alert
if (now.compareTo(last_eventGdt) >= 0){
alertGr.setValue("state","Closed");
alertGr.getElement("work_notes").setDisplayValue(gs.getMessage("Alert is automatically closed when it is idle for more than {0} hours.", [CLOSE_INTERVAL]));
alertGr.update();
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 02:42 PM
Dominic,
The scheduled job, 'Event Management - auto close alerts', handles this function. It's logic appears to be comparing, in seconds, the alert's last update time vs now.
var CLOSE_INTERVAL = GlideProperties.get('evt_mgmt.alert_auto_close_interval', 168);
if (parseInt(CLOSE_INTERVAL) > 0){
var alertGr = new GlideRecord("em_alert");
alertGr.addQuery("state","!=","Closed");
alertGr.query();
while(alertGr.next()){
var last_event = alertGr.getValue("sys_updated_on");
var last_eventGdt = new GlideDateTime(last_event);
var now = new GlideDateTime();
last_eventGdt.addSeconds(CLOSE_INTERVAL*3600);//1 hour = 3600 seconds
//it's time to close the alert
if (now.compareTo(last_eventGdt) >= 0){
alertGr.setValue("state","Closed");
alertGr.getElement("work_notes").setDisplayValue(gs.getMessage("Alert is automatically closed when it is idle for more than {0} hours.", [CLOSE_INTERVAL]));
alertGr.update();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 03:02 PM
Thanks Christian. I assumed that it would go off of updated time, but the documentation was far from clear on the subject. I very much appreciate your prompt answer (which is being marked as correct).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 04:00 PM
Party on Dominic!