- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi Community,
I am working on a requirement where I need to send email notifications to all users present in the Watch List field of a record (e.g., Incident, Case, or any custom table) using Business Rules, Events, Notifications, and Email Scripts.
Requirement Details:
Whenever a record is inserted or updated, all users added in the Watch List should receive an email notification.
The solution should use:
Business Rule to trigger the logic
Event to queue the notification
Notification configuration
Email Script to dynamically fetch and send emails to all watch list users
Points I Need Help With:
How to parse the watch list field (comma-separated sys_ids) correctly?
Best practice to trigger an event from a Business Rule for watch list users.
How to configure the notification to send emails to multiple recipients dynamically?
Sample Business Rule + Event + Email Script code for this use case.
Use Case Example:
Table: Incident
Field:
watch_listWhen Incident is updated → All users in Watch List should get an email.
Any best practices, sample scripts, or step-by-step guidance would be really helpful.
Thanks in advance for your support!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
hey @sarthakkach
Follow this :
Step 1 – Create Event
Name: incident.watchlist.notify
Table: Incident
Step 2 – Business Rule (Trigger the Event)
Type: After
When: Insert and Update
Table: Incident
Condition:
Only trigger if watch_list changes:
current.watch_list.changes()
Script:
(function executeRule(current, previous) {
if (!current.watch_list.nil()) {
gs.eventQueue(
'incident.watchlist.notify',
current,
current.watch_list.toString(),
gs.getUserID()
);
}
})(current, previous);Step 3 – Create Notification
Name: Incident Watch List Notification
Table: Incident
When to send: Event is fired
Event name: incident.watchlist.notify
Step 4 – Email Script ( for Dynamic Recipient Handling)
Create Email Script:
Name: Add Watchlist Recipients
Script:
(function runMailScript(current, template, email, event) {
var watchList = event.parm1;
if (!watchList)
return;
var userGR = new GlideRecord('sys_user');
userGR.addQuery('sys_id', 'IN', watchList);
userGR.query();
while (userGR.next()) {
if (userGR.email) {
email.addAddress('to', userGR.email.toString());
}
}
})(current, template, email, event);
Then include this Email Script inside the Notification:
${mail_script:Add Watchlist Recipients}
*************************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
hey @sarthakkach
Follow this :
Step 1 – Create Event
Name: incident.watchlist.notify
Table: Incident
Step 2 – Business Rule (Trigger the Event)
Type: After
When: Insert and Update
Table: Incident
Condition:
Only trigger if watch_list changes:
current.watch_list.changes()
Script:
(function executeRule(current, previous) {
if (!current.watch_list.nil()) {
gs.eventQueue(
'incident.watchlist.notify',
current,
current.watch_list.toString(),
gs.getUserID()
);
}
})(current, previous);Step 3 – Create Notification
Name: Incident Watch List Notification
Table: Incident
When to send: Event is fired
Event name: incident.watchlist.notify
Step 4 – Email Script ( for Dynamic Recipient Handling)
Create Email Script:
Name: Add Watchlist Recipients
Script:
(function runMailScript(current, template, email, event) {
var watchList = event.parm1;
if (!watchList)
return;
var userGR = new GlideRecord('sys_user');
userGR.addQuery('sys_id', 'IN', watchList);
userGR.query();
while (userGR.next()) {
if (userGR.email) {
email.addAddress('to', userGR.email.toString());
}
}
})(current, template, email, event);
Then include this Email Script inside the Notification:
${mail_script:Add Watchlist Recipients}
*************************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hello @sarthakkach ,
have a look on this, it should help you :
https://www.servicenow.com/community/developer-forum/notification-to-send-to-users-when-they-are-add...
https://www.servicenow.com/community/developer-forum/email-notification-for-watchlist/m-p/2019117#:~...
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
36m ago - last edited 36m ago
Hi @sarthakkach ,
Step by step instructions (with screen shot) are given in this Community test. Go through it . Hope it will help you.
https://www.servicenow.com/community/developer-forum/email-notification-for-watchlist/m-p/2019117

