Notification email script not working - could really use some help!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 04:58 PM
Hello SN Developer Community!!
I have a requirement to send all external notifications to users on the email "bcc" field, rather than the "to" or "cc" field. The notifications are running against a custom table (u_operational_mechanical_incident) where there are custom incident forms and based on one field on each form called "Customers" (u_users) - please see screenshot below.
I have 3 notifications for Urgent / High incidents that have the mail script (copied below) added to the body of the email(s) - but the notifications are still listing the customers out on the "To" field, rather than the "Bcc" field. Can anyone please tell me what I'm doing wrong here?
(function runMailScript( /*GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /*Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var user = new GlideRecord("u_operational_mechanical_incident");
user.addQuery("u_users", current.getUniqueValue());
user.addQuery("email", "!=", "");
user.query();
while (user.next()) {
email.addAddress("bcc", user.getValue('email'), user.getValue('name'));
}
})(current, template, email, email_action, event);
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 06:27 PM
Nya,
Please check example below from
https://docs.servicenow.com/bundle/kingston-servicenow-platform/page/script/server-scripting/reference/r_ExScptEmlNtfn.html
//email.addAddress(type, address, displayname); email.addAddress("cc","john.copy@example.com","John Roberts"); email.addAddress("bcc","john.secret@example.com","John Roberts");

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 06:34 PM
Thank you so much!! I've actually tried it using that document as a template for mine and it did not work either ... I'm really stumped on why it's not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 08:57 PM
Hi,
If you are adding same user on To list and BCC list then system will not show that user in BCC list.
Could you please provide recipient configuration screenshot at notification level and example triggered email screenshot so that it will be clear for us to debug/understand issue further.
Please mark this as Correct or helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 08:00 AM
Hello Abhijit!
Thank you so much for your help to investigate this issue. Please find below a screenshot of the notification tab: "Who will receive" and also an example of the triggered email as well. Any help you can provide is GREATLY appreciated!!!
Notification configuration:
Notification itself (from Outbox):
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 09:09 PM
Hi,
Make sure to set the value of this Property "glide.email.test.user" to blank as shown below:
1) Navigate to Properties module by typing "sys_properties.LIST" as shown below:
2) Search for this property "glide.email.test.user" and make the value as Empty as shown below:
If "glide.email.test.user" property is set then ServiceNow only set the "To" Recipient in the Email Headers even if the configurations are for CC and BCC field over the script it will be disregarded.
If this property is set to empty value then we set To / CC / BCC as well. Please empty this property to achieve populating CC and BCC.
Please refer the HI Article below for more details on this:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783517
Also do refer to below HI Article as well and see if this helps:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0830775
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke