Email Notification Not triggered to an e mail address in CC with Priority changed for an incident

Nilanjan1
Giga Sage

Dear Experts, 

 

I am running into an issue. I drew a notification script for specific user groups.. The notification is getting triggered to a specific group e mail address in CC but when the priority is raised, the notification is going to the group members but the cc (group e mail)  is missing. what Can be the reason. A quick reply will be appreciated.

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    // Add your code here

    var propertyValue = gs.getProperty('evr.incident.notification.groups', '');
    if (!propertyValue)
        return;

    var targetGroups = propertyValue.split(',');
    var currentGroup = current.getValue('assignment_group');

    var isTargetGroup = false;
    //Check if the current record has an assignment group in our property list
    if (current.isValidField('assignment_group') && !current.assignment_group.nil()) {
        isTargetGroup = targetGroups.indexOf(currentGroup) !== -1;
    }
    var isPriorityChanged = current.priority.changes();
    //gs.log('isTargetGroup: ' + isTargetGroup + ', isPriorityChanged: ' + isPriorityChanged, 'company_NOTIFY');
    if (isTargetGroup || isPriorityChanged) {
        email.addAddress('cc', 'M365Support@company.com', 'M365 Support');
        //gs.log('Added CC: M365Support@company.com', 'NB_NOTIFY');
    }



})(current, template, email, email_action, event);

 

1 REPLY 1

Tanushree Maiti
Tera Patron

Hi @Nilanjan1 

 

Instead Of following line 

 var isPriorityChanged = current.priority.changes();

Try with mentioning Priority and try 

 

var isPriorityRaised = (current.priority == 1 || current.priority == 2);

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti