- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 05:38 AM
Hi ,
I have a list collector field in a table , which is referencing to user table , my requirement is to add those users in a email cc , so how can we do this via email scripts or any other ways ?
Thanking you in advance...
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 10:00 AM
Hi @Amit Dey1
This thread has details on using a list collector in a notification email script. Copying the script used in the thread here:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
if (!current.<manager_list_variable_name_goes_here>.nil()) {
//get watch list addresses and add to bcc
var watcherIds = current.<manager_list_variable_name_goes_here>.split(",");
//get user records
var user = new GlideRecord("sys_user");
user.addQuery("sys_id", "IN", watcherIds);
user.addQuery("email", "!=", "");
user.query();
while (user.next()) {
//add to cc list
email.addAddress("cc", user.getValue('email'), user.getDisplayValue()); //Carbon Copy
//email.addAddress("bcc", user.getValue('email'), user.getDisplayValue()); //Blind Carbon Copy
}
}
})(current, template, email, email_action, event);
Product documentation referenced in that post here.
Hope this was helpful!
-Matt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 10:00 AM
Hi @Amit Dey1
This thread has details on using a list collector in a notification email script. Copying the script used in the thread here:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
if (!current.<manager_list_variable_name_goes_here>.nil()) {
//get watch list addresses and add to bcc
var watcherIds = current.<manager_list_variable_name_goes_here>.split(",");
//get user records
var user = new GlideRecord("sys_user");
user.addQuery("sys_id", "IN", watcherIds);
user.addQuery("email", "!=", "");
user.query();
while (user.next()) {
//add to cc list
email.addAddress("cc", user.getValue('email'), user.getDisplayValue()); //Carbon Copy
//email.addAddress("bcc", user.getValue('email'), user.getDisplayValue()); //Blind Carbon Copy
}
}
})(current, template, email, email_action, event);
Product documentation referenced in that post here.
Hope this was helpful!
-Matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 03:34 AM
It worked Thanks