- 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
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:50 AM
Hi @NiloferS,
please check below links:
https://www.youtube.com/watch?v=_yZ3ZOVf05Y
https://www.youtube.com/watch?v=2k7szQymVBM
Thank you, please make helpful if you accept the solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 02:58 AM
Hi @NiloferS
-> You need to create a email script and define the user you want to set as cc in email and then call the email script from the notification.
Steps to create Email Script and how to use:
- Navigate to the "Notification email Script" in the "System Notification" in filter navigator.
- Set the name of email notification "add_newusers_to_cc".
- add below code in the script:
email.addAddress("cc","email_address_of_the_user","Name_of_ther_user"); //if you want to push the user dynamically then you can use the scripting to validate and push the user.
4. Now navigate to the notification where you want to add cc.
5. add "${mail_script:add_newusers_to_cc}" in "Message HTML" field in "What it will contain" form section of notification.
Kindly mark my answer as Correct and helpful based on the Impact.