Email notification for Incident owner when Problem closed

Sam179
Tera Contributor

Hi all,

I have a requirement to email incident owner when a problem is closed. The problem can have a single or multiple incidents attached to a single problem. My question is how to email the incident owner or multiple incidents owner attached to the problem when a problem is closed?

1 ACCEPTED SOLUTION

Harshinya1
Mega Guru

I tried below code and it worked.

1. Create an event using event registry

find_real_file.png

2. Create a notification on problem table to trigger when event is fired and create notification body and subject as per your requirements. Also see who will receive section snippet below for recipients

find_real_file.png

find_real_file.png

 

3. Create an on After business rule on problem table  with condition to trigger when state of the problem changes to closed/resolved

(function executeRule(current, previous /*null when async*/) {
var incidentOwners = [];
var incidentAssignee = [];
var incidentGR = new GlideRecord("incident");
incidentGR.addQuery("problem_id", current.sys_id);
incidentGR.addActiveQuery();
//Can add additional conditions like below based on requirements;
/*
incidentGR.addQuery("state", IncidentState.AWAITING_PROBLEM);
incidentGR.addQuery("hold_reason", IncidentReason.AWAITING_PROBLEM);*/
incidentGR.query();
while (incidentGR.next()) {
incidentAssignee.push(incidentGR.getValue('assigned_to'));
incidentOwners.push(incidentGR.getValue('caller_id')); //Modified Incident Owner field name accordingly
}

if (incidentOwners.length >0 || incidentAssignee.length >0)
gs.eventQueue('incident.problem_close', current, incidentAssignee.toString(), incidentOwners.toString(), '');

})(current, previous);

 

Hope this helps

 

View solution in original post

5 REPLIES 5

RG6
Tera Contributor

I tried cloning the same to send the alert to end users, which apparently isn't working. Which would be the best way to update both incident owners and end users?