
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2016 07:34 AM
I need to add two users to the CC field of an approval email notification template. I was told to use mail script but not sure how to write the script, any thoughts? The two field I need to add are "Primary Triage" and "Back Up Triage" which both are reference field to the sys_user table.
Thanks,
Edwin
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016 12:07 PM
If that is the case use this script. MAke sure your field names are correct
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var ids=current.sysapproval.<primary triage>+','+current.sysapproval.<backup triage>;
var user = new GlideRecord("sys_user");
user.addQuery("sys_id","IN",ids);
user.addQuery("email", "!=", "");
user.query();
while (user.next()) {
//add to cc list
email.addAddress("cc", user.email, user.getDisplayValue());
}
})(current, template, email, email_action, event);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016 11:46 AM
Thank you... Still not working for some reason, but below is the full scenario.
When the "Status" field changes to "Rebuttal Review" an approval is generated to the "Requested For" user. The approval runs on the "sysapproval_approver" table and not the "ConnectUs" table. Since the two fields "primary_triage" and "back_up_triage" belong to the "ConnectUs" table could that be why I'm not able to get the two fields in the CC field?
Thanks,
Edwin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016 12:07 PM
If that is the case use this script. MAke sure your field names are correct
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var ids=current.sysapproval.<primary triage>+','+current.sysapproval.<backup triage>;
var user = new GlideRecord("sys_user");
user.addQuery("sys_id","IN",ids);
user.addQuery("email", "!=", "");
user.query();
while (user.next()) {
//add to cc list
email.addAddress("cc", user.email, user.getDisplayValue());
}
})(current, template, email, email_action, event);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016 12:45 PM
Thank you, Thank you, Thank you.. That worked!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016 12:48 PM
You are welcome!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 02:20 AM
Hi Abhinay, I have tried this script exactly but it is not working for me on Pdi