
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 08:03 AM
Hello All,
We have a requirement where in notifications should go to all the affected users in the related list not just one in the Affected user field on the form.Whats happening right now is the notification is only being sent to the person in affected user field, not for multiple users in the related list
Solved! Go to Solution.
- Labels:
-
Security Incident Response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 09:40 AM
use below script in mail script. Glide Proper table which is present on related list and field names.
var gr = new GlideRecord("Related list table Name");
gr.addQuery("task", current.sys_id);
gr.query();
while (gr.next()) {
email.addAddress("cc", gr.user.email, gr.name);
}
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 08:54 AM
Yes.
If you want the dynamic affected users list then you will have to use that. To get the users list.
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 09:26 AM
Thank you Gunjan for the insight , could you help me with a sample script here ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 09:40 AM
use below script in mail script. Glide Proper table which is present on related list and field names.
var gr = new GlideRecord("Related list table Name");
gr.addQuery("task", current.sys_id);
gr.query();
while (gr.next()) {
email.addAddress("cc", gr.user.email, gr.name);
}
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 11:12 AM
gunjanm,
thank you for the response.
I have configured the email script as mentioned and created a simple notification. It is still sending notification to 1 affected user. I cannot fathom what am I missing here.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 09:34 AM
You can create an email script and add it to your notifications
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
if(event.user_id=='system'){
var user = new GlideRecord("m2m_table");
user.addQuery("parent",current.getUniqueValue());
user.query();
while(user.next()){
email.addAddress("bcc",user.getValue('email_address'),user.getValue('name'));
}
}
})(current, template, email, email_action, event);