- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 01:12 PM
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?
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 10:05 PM
I tried below code and it worked.
1. Create an event using event registry
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2020 10:01 PM
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?