
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2020 06:03 PM
Hi all,
Looking for help w/ adding multiple users to CC in a notification. I am using a mail script w/ the email.addAddress() function and I am getting the right output (per logs) but the mail doesn't appear to be going to the listed users.
Scenario: When a requested item is awaiting approval, sometimes the approver doesn't respond. If the requester (or anyone really) leaves a comment we have it so a notification including that comment goes to both the requested-for user and the current approver(s) for the requested item.
This is proving insufficient in our org and I need to add our IT Service Desk group members to the CC on these notifications so they can be more proactive in responding when people see that things are hung up.
The mail script I'm using is thus:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var sdesk = []; // declare array to push IT Service Desk group member emails into
var sd = new GlideRecord('sys_user_grmember');
sd.addQuery('group','e3988a82dbda3e00641b572e5e9619bb'); // sys_id of the IT Service Desk group
sd.query();
while (sd.next()) {
sdesk.push(sd.user.email);
}
gs.log(sdesk.toString());
email.addAddress("cc",sdesk.toString(),"IT Service Desk");
})(current, template, email, email_action, event);
The logs show the correct users, but (having added the 'Copied' field to the sent sys_email form) the recipients are not showing up in the email.
Thanks in advance for any tips here!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2020 06:17 PM
Try this
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var sd = new GlideRecord('sys_user_grmember');
sd.addQuery('group','e3988a82dbda3e00641b572e5e9619bb'); // sys_id of the IT Service Desk group
sd.query();
while (sd.next()) {
email.addAddress("cc",sd.user.email,"IT Service Desk");
}
})(current, template, email, email_action, event);
For Reference see the last example script on the below link where users are getting added to CC from watch list.
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2020 08:59 PM
Hey Aaron ,
Checkout this :
Mark Correct and Helpful if it helps!!!
Best Regards,
Namrata.