Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2024 07:23 AM
Can I please get some help scripting an Email Script to bcc the "Assigned To"
Here is my current script that is not working:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// This works:
// email.addAddress("bcc", "abel.tuter@example.com", "Abel Tuter");
//This is Not working:
// Get Assigned PM address and add to BCC
var assignedTo = current.u_assigned_to;
// Get user record
var user = new GlideRecord('sys_user');
user.addQuery("sys_id", assignedTo);
user.addQuery("notification", 2);
user.query();
// Add to BCC list
email.addAddress("bcc", user.email, user.getDisplayValue());
})(current, template, email, email_action, event);
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2024 07:34 AM
Hi @Su522 ,
Try the below:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// This works:
// email.addAddress("bcc", "abel.tuter@example.com", "Abel Tuter");
// Get Assigned PM address and add to BCC
var assignedTo = current.u_assigned_to;
// Get user record
var user = new GlideRecord('sys_user');
user.addQuery("sys_id", assignedTo);
user.addQuery("notification", 2);
user.query();
while(user.next()){
// Add to BCC list
email.addAddress("bcc", user.getValue('email'), user.getValue('name'));
}
})(current, template, email, email_action, event);
----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.
Mark this as Helpful / Accept the Solution if this helps.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2024 07:34 AM
Hi @Su522 ,
Try the below:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// This works:
// email.addAddress("bcc", "abel.tuter@example.com", "Abel Tuter");
// Get Assigned PM address and add to BCC
var assignedTo = current.u_assigned_to;
// Get user record
var user = new GlideRecord('sys_user');
user.addQuery("sys_id", assignedTo);
user.addQuery("notification", 2);
user.query();
while(user.next()){
// Add to BCC list
email.addAddress("bcc", user.getValue('email'), user.getValue('name'));
}
})(current, template, email, email_action, event);
----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.
Mark this as Helpful / Accept the Solution if this helps.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2024 07:39 AM