Notification email script to add related team members

Nishant16
Tera Expert

Need to add the recipients of Account team members of a case with Responsibility definition of "Account Manager" to the outgoing emails for a case, I tried the below email script but not working.
can someone help me please.

Below is the email script

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

          // Add your code here
	
    var groupMembers = new GlideRecord('sn_customerservice_team_member');
    groupMembers.addQuery('account', current.account.sys_id);
    groupMembers.addEncodedQuery('responsibility=d151dbgeddbt654d49d2dce46ld786fg3'); //Responsibility is Account Manager
    groupMembers.query();
    while (groupMembers.next()) {
			email.addAddress("cc",  groupMembers.user.email, groupMembers.user.getDisplayValue());
        }

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

 

1 ACCEPTED SOLUTION

Good catch on the suggestion with the Group, that should eliminate the scripting need. Probably.

 

Also, I'm assuming the sn_customerservice_team_member table is a M2M table.

So the suggestion with getDisplayValue will not work, unless you make some modifications.

First you'll need to get that record.

Something like this:

 while (groupMembers.next()) {
        var userGR = groupMembers.user.getRefRecord();
	email.addAddress("cc",  groupMembers.user.email.toString(), userGR.getDisplayValue());
 }

 

View solution in original post

5 REPLIES 5

Good catch on the suggestion with the Group, that should eliminate the scripting need. Probably.

 

Also, I'm assuming the sn_customerservice_team_member table is a M2M table.

So the suggestion with getDisplayValue will not work, unless you make some modifications.

First you'll need to get that record.

Something like this:

 while (groupMembers.next()) {
        var userGR = groupMembers.user.getRefRecord();
	email.addAddress("cc",  groupMembers.user.email.toString(), userGR.getDisplayValue());
 }