Add email to notification before sending
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2025 05:43 AM
I am having one requirement to add a email of a person to a notification before they are sent from ServiceNow instance. If there is new notification created then I don't want to add mail script to every notification and it wont be possible to add too add this user based on some condition. How can I add user to notification dynamically?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2025 10:07 AM
If all of your notifications share an email layout, you can place the mail script within the layout record. This will then be inherited.
Otherwise a business rule would be needed on the sys_email table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2025 07:57 AM
Hello @rishabhkata
How about writing a BR on sys_email table as configured below:
and script something as below:
(function executeRule(current, previous /*null when async*/ ) {
// Fetch the existing value from the "recipients" field
var recipients = current.recipients;
// Define the new emails to be added
var newEmails = ['v@example.com', 'x@example.com'];
// Check if the recipients field is not empty
if (recipients) {
// Split the existing recipients into an array
var recipientArray = recipients.split(',');
// Add the new emails to the array
recipientArray = recipientArray.concat(newEmails);
// Remove any empty strings from the array
recipientArray = recipientArray.filter(function(email) {
return email.trim() !== '';
});
// Join the array back into a string with comma separator
recipients = recipientArray.join(',');
} else {
// If the recipients field is empty, just join the new emails
recipients = newEmails.join(',');
}
// Update the "recipients" field with the new value
current.recipients = recipients;
})(current, previous);
Note: Do test this and use this carefully as this will apply performance issue as it will be trigger on every email record sent out. Since you don't need to add through email script so this can be only approach, but test it thoroughly discuss with architect and then go with this over prod.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2025 08:04 AM
@Viraj Hudlikar This won't work as email is already in the send queue and updating this record will only update recipient in our ServiceNow system but it won't trigger the notification to the user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2025 08:08 AM
@rishabhkata You can try to execute BR before insert data on this table which will be append your additional recipients as unless type changes emails are not triggered from system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2025 08:10 AM
@Viraj Hudlikar I have already tried this same approach and user is not receiving any email but our servicenow is showing that it is sent to both users