What is the best way to send a notification using Business Rule, Script Action, or Email Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
"What is the best way to send a notification — including the Problem number and short description — when a Problem is created from an Incident, and should we use a Business Rule, Script Action, or Email Script for this, and in what order should each be executed?"
1. Business Rule (After Insert on Problem table)
(function executeRule(current, previous /*null when async*/) {
if (current.parent_incident) {
gs.eventQueue('custom.problem.created.from.incident', current, current.sys_id, current.parent_incident.sys_id);
}
})(current, previous);
2. Script Action (Triggered by Event)
var problem = current;
var incident = new GlideRecord('incident');
if (incident.get(event.parm2)) {
var email = new GlideEmailOutbound();
email.setSubject("New Problem Created from Incident: " + problem.number);
email.setBody("A Problem has been created.\n\nProblem: " + problem.number +
"\nShort Description: " + problem.short_description +
"\nRelated Incident: " + incident.number);
email.setRecipient(incident.caller_id.email);
email.send();
}
3. Email Notification
(function runMailScript( current, template,
email, email_action, event) {
var gr = new GlideRecord("problem");
gr.short_description = current.short_description;
var pid = gr.insert();
current.setValue('problem_id', pid);
current.problem_id = gr.sys_id;
current.setWorkflow(false);
current.update();
template.print("Problem Number: " + gr.number);
template.print("Problem Short Desc" + gr.short_description);
})(current, template, email, email_action, event);