
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 11:12 AM
Hiii !
I made this little script in the Email Script:
(function runMailScript(current, template, email, email_action, event) {
var gr = new GlideRecord("test");
var encodedQuery = gs.getProperty("x_encodedQuery");
gr.addEncodedQuery(encodedQuery);
gr.query();
while (gr.next()) {
email.addAddress("cc", gr.pu_user.email, gr.pu_user.getDisplayValue());
}
but it is not working for me. When I do the preview in the notification it doesn't show me any of the emails, it's all blank. I only did this email script and in the template part of the notification I put the name of the template, but nothing else. Could it be that I missed something? Thank you very much.
Solved! Go to Solution.
- Labels:
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 02:49 PM
Hi,
I've seen this and your other post and so this circles back to a "To" recipient.
If you're wanting these users to be listed as the "To" and to ensure this notification goes out, you'd want to create an event, then trigger the event, which you'd then set your notification to fire upon event trigger.
So you would make this decision in a business rule or somewhere else and give the list of recipients to your event to pass to the notification. In the "who to send to" tab, you would check (for example): parm1 contains recipients as well as send to event creator.
Your event script could look like:
var userArray = [];
var gr = new GlideRecord('sys_user');
gr.addQuery('company', 'sys_id_here');
gr.addQuery('vip', true);
gr.query();
while (gr.next()) {
userArray.push(gr.sys_id);
}
if (userArray.length > 0) {
gs.eventQueue('name_of_event', current, userArray.toString(), '');
}
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 11:15 AM
Hi there,
In preview indeed it can be that CC is not shown. I've experienced this multiple times. Though when sending an actual email, the CC works fine for me.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 11:19 AM
Hi
When you check the email in the logs. There is a field called "copied". Can you see the emails you are adding in that field.
Please mark my answer as correct/helpful, if it helps.
Thanks
Sukhbir Singh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 01:48 PM
Any update on ths? I see you just posted a new question, so maybe you can answer this one?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 02:00 PM
Hello Mark! No, the question I just asked is related to this one, no answer helped me 😞
The script was not bad, I found the notification is sent but only when there is a user as a recipient, but I do not want to put anyone as a recipient. Maybe there is some solution to add to emails instead of cc, as recipient through the script. Thanks for asking!