- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
20 hours ago
i have created below email script and using this in the email Message HTML , but not able to see the added members in the cc , can anyone please help me with this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
19 hours ago
Hi @priyankmish
- Your script looks good to me if you are calling this in notifications, but it requires validation for all the values. If any of the values where you have applied dot-walking are undefined/null, the script won’t work.
Look at this video, here it is explained to apply validations-
https://www.youtube.com/watch?v=2k7szQymVBM
- Another possible reason — if you have any value configured in the property: glide.email.test.user
then the notification may not work as expected for CC/BCC.
ServiceNow Article :- https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783517
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
19 hours ago
Hi @priyankmish
Add gs.log and check whether you dot walking field showing you to correct value
Sample code:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var groupMembers = new GlideRecord('sys_user_grmember');
groupMembers.addQuery('group.name', 'Group A'); //Query it as per your requirement
groupMembers.addEncodedQuery('user.emailISNOTEMPTY');
groupMembers.query();
while (groupMembers.next()) {
var userEmail = groupMembers.user.email;
var userName = groupMembers.user.getDisplayValue();
if (userEmail) {
email.addAddress('cc', userEmail, userName);
} else {
gs.log("User " + userName + " does not have a valid email address.");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
19 hours ago
I have verified this using a background script, where I was able to retrieve all email addresses. Also, both the notification and the mail script belong to the sn_retail scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
19 hours ago
Hi @priyankmish
- Your script looks good to me if you are calling this in notifications, but it requires validation for all the values. If any of the values where you have applied dot-walking are undefined/null, the script won’t work.
Look at this video, here it is explained to apply validations-
https://www.youtube.com/watch?v=2k7szQymVBM
- Another possible reason — if you have any value configured in the property: glide.email.test.user
then the notification may not work as expected for CC/BCC.
ServiceNow Article :- https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783517
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
18 hours ago
share script here and not image for script
Also what debugging did you do from your side?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
