How to send notification only to Internal users excluding external users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 04:29 AM
Hi
How to Achieve
Notification to send only to internal users not for external users
when external users are present on incident watchlist
I want to send notification only to internal users of watchlist exluding external users
Like In watch list if we have abc@company.com
It should send notification
If in watch list we have abc@noncompany.com
It should not send notification
can we write any scripted condition in notification under advance condition
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 04:38 AM
Hello @Research,
To send notifications only to internal users of a watchlist, excluding external users, you can use the Advanced Condition option in the notification settings. This option allows you to write a custom script that evaluates to true or false, and determines whet....
One possible way to write a scripted condition for your requirement is to use the following logic:
- Get the watchlist field value from the current record
- Split the watchlist value into an array of email addresses
- Loop through the array and check if each email address belongs to an internal or external user
- If an internal user is found, set a flag variable to true and break the loop
- Return the flag variable as the result of the script
Here is an example of how the script might look like in Javascript:
// Get the watchlist field value from the current record
var watchlist = current.watch_list;
// Split the watchlist value into an array of email addresses
var emails = watchlist.split(',');
// Initialize a flag variable to false
var sendNotification = false;
// Loop through the array and check if each email address belongs to an internal or external user
for (var i = 0; i < emails.length; i++) {
// Trim any whitespace from the email address
var email = emails[i].trim();
// Check if the email address contains the domain name of your company
// You can change this condition according to your criteria for internal users
if (email.indexOf('@company.com') > -1) {
// If an internal user is found, set the flag variable to true and break the loop
sendNotification = true;
break;
}
}
// Return the flag variable as the result of the script
return sendNotification;
Please note that this is just a sample script and you may need to modify it according to your specific needs and preferences. You can also refer to some examples and best practices for writing advanced conditions in ServiceNow...
Hope this helps.
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 09:41 AM
Really appreciate for your solution
Sorry I dint mentioned full condition like we have many accounts and users from different companys even from gmail.com
Can we add any condition like to send notification to only users which are present in sys_user table in instance. Like that.
Thanks for responding.