Closing alert should resolve incident automatically

Kumar54
Tera Contributor

In event management settings closing alerts was set to resolve incidents automatically but i see no incidents getting resolved though the alert is closed?

1 ACCEPTED SOLUTION

Hi,

Raise HI Ticket.

Thanks,
Ashutosh

View solution in original post

10 REPLIES 10

Hi Kumar,

1) How are you testing this.

2) task field on alert has incident in it?

3) Any BR on incident table restricting this.

4) Show the property screen shot which is set?


Thanks,
Ashutosh

1) Just checking Alerts which are closed and incident attached to this particular alert on task field 2)yes 3)no br on incident table restricting this 4) BR CODE: condition:((previous.state != 'Closed' && current.state == 'Closed')||(previous.severity != '5' && current.severity == '5') ||(previous.severity != '0' && current.severity == '0')) && current.incident !='NULL' && current.incident !='' && current.incident !=null Script: // This rule runs when the alert is closed. // It will resolve, or close the associated task or just add a comment to it // (checks the property alert_closes_incident) var alertManager = new SNC.AlertManager(); alertManager.addStep("Alert BR: Close associated incident (after)"); var task = new GlideRecord("task"); task.get(current.incident); var taskState = task.state; // Incident is not Resolved or Closed if ("6" != taskState && "7" != taskState) { // Check there are no alerts linked to this task that are not closed var relatedAlerts = new GlideRecord("em_alert"); relatedAlerts.addQuery("state", "!=", "Closed"); relatedAlerts.addQuery("severity", "!=", "5"); relatedAlerts.addQuery("severity", "!=", "0"); relatedAlerts.addQuery("incident", current.incident); relatedAlerts.addQuery("sys_id", "!=", current.sys_id); // skip the current alert relatedAlerts.query(); if (relatedAlerts.getRowCount() == 0) { var property = gs.getProperty('evt_mgmt.alert_closes_incident'); var stateInt; if (property == 'resolve') { stateInt = 2; } else if (property == 'close') { stateInt = 3; } else if (property == 'nothing') { stateInt = 0; } //check if the type has special behavior or handle as a task var type; var taskTypeChoicesGr = new GlideRecord("em_task_type_choices"); taskTypeChoicesGr.addQuery("type", task.sys_class_name); taskTypeChoicesGr.query(); if (!taskTypeChoicesGr.next()) type = "task"; else { type = task.sys_class_name; } //get the mapping value for the required type // var stateGr = new GlideRecord("em_task_type_choices"); taskTypeChoicesGr.initialize(); taskTypeChoicesGr.addQuery("type", type); taskTypeChoicesGr.addQuery("state", stateInt); taskTypeChoicesGr.query(); if (taskTypeChoicesGr.next()) { var value = taskTypeChoicesGr.getValue('value'); if (value != "-1") { if (type == "incident" && (value == IncidentState.RESOLVED || value == IncidentState.CLOSED)) { var incGr = new GlideRecord("incident"); incGr.get(task.getUniqueValue()); task = incGr; task.close_code = "Solved Remotely (Permanently)"; task.close_notes = "Closed the task associated with alert: " + current.number; } task.state = value; task.update(); } } } }

Hi,


BR looks good.

I think there is some other BR which is not allowing this BR to do its job. In some BR it may be written as setWorkflow(false).

Also i believe BR is active at your end.

Can you try one more thing.


Enable Debug Business Rule and then try to close one alert and see which BR are running.

 

Thanks,
Ashutosh

everything looks good and have done debug too. Is their any other way?

Hi,

Raise HI Ticket.

Thanks,
Ashutosh