We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to Send Email Notifications to All Users in Watch List Using Business Rule.

sarthakkach
Tera Contributor

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:

  1. How to parse the watch list field (comma-separated sys_ids) correctly?

  2. Best practice to trigger an event from a Business Rule for watch list users.

  3. How to configure the notification to send emails to multiple recipients dynamically?

  4. Sample Business Rule + Event + Email Script code for this use case.

Use Case Example:

  • Table: Incident

  • Field: watch_list

  • When 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!

1 ACCEPTED SOLUTION

vaishali231
Tera Guru

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

 

 

View solution in original post

3 REPLIES 3

vaishali231
Tera Guru

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

 

 

Tanushree Maiti
Giga Sage

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

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: