- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 06:25 PM
Hello!
Still learning the ins and outs of ServiceNow and the the different things that can be done with email notifications. I have an existing email notification that needs its conditions to be updated. Right now, in the 'Who will receive' tab, there is Groups SNOW Dev and SNOW Test. What's being asked, where I'm not sure how to go about, is the email notification should be dynamically set based on the environment you are in. Would anyone be able to guide a relatively new ServiceNow user on how to do this? Thank you for the time!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 07:54 PM
how are you triggering the email? using event or directly using the notification "Inserted" and "Updated" checkboxes?
To handle dynamic recipient you should use after business rule & create event on the same table as that of the notification
Then based on your logic you can set the recipients via triggering the event.
I hope I have answered your question and you can enhance it further based on your requirement.
1) create event on your table
2) make notification trigger on that event, ensure "Event parm1 contains recipient" is checked
3) use business rule to trigger the event
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var recipient = '';
var instanceName = gs.getProperty('instance_name');
if (instanceName == 'dev instance')
recipient = 'groupSysIdForDev';
else if (instanceName == 'test instance')
recipient = 'groupSysIdForTest';
gs.eventQueue('event_name', current, recipient);
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2025 05:57 AM
Hi Ankur, quick question. For this solution, once I get the sys_id of the group and apply it to the script. This will send the email to the Group Members of that group, correct?