- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2023 06:47 AM
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);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2023 12:56 PM
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());
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2023 07:15 AM
Hi,
Can you explain in more detail what the issue is?
Does not query not work/not return any results?
Does the attaching of CC to the email not work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2023 12:59 AM
Hi Olan,
Query is returning the result, but unable to attach the user to cc

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2023 07:57 AM
Try changing the second parameter to this:
groupMembers.user.email.toString()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2023 10:06 AM
Nishant16,
Why don't you send the notification to the group? No script needed.
Also your syntax is wrong on groupMembers.user.getDisplayValue();
it should be groupMembers.getDisplayValue('user');