Email notification using List Collector Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2022 05:58 PM
We have a custom field on a table that is a list collector.
When the work notes are updated on a record, we need to send a notification to all users in the list.
I've been trying to do this with an event and business rule but it isn't working.
The list field is "manager_name".
If someone could please provide clear instructions/script on how to accomplish this, it would be greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 07:35 AM
The log states the following:
Notification 'test worknotes' (2a0fc5d01b86d11096b243f3cc4bcbbb) excluded recipients because user's device contains an empty or invalid email address (see "cmn_notif_device.email_address")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 07:35 PM
That sounds like the sys_user record does not have a primary email 'cmn_notif_device' record configured (user email address is sourced from cmn_notif_device table not directly from sys_user record.email).
Have you checked cmn_notif_device table to confirm that the user has a primary email device configured?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2022 08:57 PM
After a little more testing, it seems that no notifications are being sent to the watchlist.
I tested this with a notification we have that is supposed to be sent to the assignment group and the watchlist when the work notes are updated on an incident.
I added a user to the watchlist (who has an email in their profile and notifications are enabled), I then added a comment to the worknotes. The notification was sent ONLY to the assignment group and NOT the watchlist. Is this a deeper issue that I should open a support ticket for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2022 11:13 PM
Hi
List collector type field should ideally not create any issue. It is supported OOTB for notifications. Possible reasons could:
- All the Users in the List Collector do not have emails in their records
- If emails are there then might be Primary email device records are not created in the table "cmn_notif_device" which is done by OOTB Business Rule "Create primary email device" on sys_user table
Nevertheless, if the above pointers are sorted then you have a workaround to send emails to the Users in List Collector through Notification Email Script which is provided below:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
if (!current.<manager_list_variable_name_goes_here>.nil()) {
//get watch list addresses and add to bcc
var watcherIds = current.<manager_list_variable_name_goes_here>.split(",");
//get user records
var user = new GlideRecord("sys_user");
user.addQuery("sys_id", "IN", watcherIds);
user.addQuery("email", "!=", "");
user.query();
while (user.next()) {
//add to cc list
email.addAddress("cc", user.getValue('email'), user.getDisplayValue()); //Carbon Copy
//email.addAddress("bcc", user.getValue('email'), user.getDisplayValue()); //Blind Carbon Copy
}
}
})(current, template, email, email_action, event);
You can also refer "Example scripting for email notifications"
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik