The Zurich release has arrived! Interested in new features and functionalities? Click here for more

What is the best way to send a notification when a Problem is created from an Incident server side

PrathameshD3158
Tera Contributor

"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( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    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);




0 REPLIES 0