Using Recipient List to populate Notification recipients
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi all,
We use a Recipient List to dynamically build our Major Incident recipients, this works great within Task Communications Management. The recipient list is added to the email client template when sending Comms for a P1/P2.
What I want to achieve is to be able to use this Recipient List (sn_publications_recipients_list) in standard Notifications (sysevent_email_action). For further context, I want to use this RL in Change Management. When a change is scheduled, I want an auomtated email sent with a summary of the change details to this list (hence notification with conditions).
In notifications theres no simple UI option to add a RL, you can only add Users/Groups. So I've tried using a mail script to query the list, and to add the comma seperated email addresses to the To field of the notification. The mail script is placed in the Email Template the notification uses. Is this method even possible? Is this script correct?
(function() {
var emails = [];
var gr = new GlideRecord('sys_publication_recipients_list');
gr.addQuery('list', 'dce37463fb9d96106e3ef92abeefdccc');
gr.query();
while (gr.next()) {
if (gr.user.email) {
emails.push(gr.user.email.toString());
}
}
if (emails.length > 0) {
template.print('${mail_add_recipients:' + emails.join(',') + '}');
}
})();
The notification is sending, but there are no recipients added. Beyond this, the only other options I see is to create a sys_user_group from the RL (via a BR?) and add that.
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
20m ago
share some screenshots.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8m ago
Hi @Ankur Bawiskar
Here's my Recipient List:
Here user.email is available
In my notification I can only add the following users and groups as recipients. I've left this empty in case this was conflicting with the mail script:
So my mail script from original post is inserted here, within the Email Template:
When I trigger the notification (which is simply Change Request state changes to Scheduled), no email is sent, as presumably there are no recipients. If I add add a user to "Who will Receive", the notifications works fine.
