- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 02:04 AM - edited 06-14-2024 02:10 AM
I have a custom table and the form as below:
We want Recipient in cc of email notification. I have written a email script as below:
Its not working as expected.
The email template has nothing mentioned in it, so its not overriding my code.
Note: this email notification is not Global. It is restricted a particular application
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 02:37 AM
your email script should be like this
(function runMailScript(current, template, email, email_action, event) {
email.addAddress('cc',current.recipient.email.toString(),current.recipient.name.toString());
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 02:38 AM - edited 06-14-2024 02:42 AM
Hi @NiloferS ,
If you have single recipient you can try script suggested by Ankur if you have multiple recipients try below script in email script
if(!current.recipient.nil()){
var watcherIds = current.recipient.split(",");
var user =new GlideRecord("sys_user");
user.addQuery("sys_id", watcherIds);
user.addQuery("email","!=","");
user.query();
while(user.next()){
email.addAddress("cc", user.email, user.getDisplayValue());
}
}
In Notification: ${mail_script:your_mailscript_name}
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 02:37 AM
your email script should be like this
(function runMailScript(current, template, email, email_action, event) {
email.addAddress('cc',current.recipient.email.toString(),current.recipient.name.toString());
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Ankur Bawiskar ,
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
please post a separate question for this, share all the details and tag me there
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 02:38 AM - edited 06-14-2024 02:42 AM
Hi @NiloferS ,
If you have single recipient you can try script suggested by Ankur if you have multiple recipients try below script in email script
if(!current.recipient.nil()){
var watcherIds = current.recipient.split(",");
var user =new GlideRecord("sys_user");
user.addQuery("sys_id", watcherIds);
user.addQuery("email","!=","");
user.query();
while(user.next()){
email.addAddress("cc", user.email, user.getDisplayValue());
}
}
In Notification: ${mail_script:your_mailscript_name}
Thanks,
Anand
