- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 04:37 AM
Hi everyone,
I need help configuring a notification in ServiceNow to notify only the newly added users in the Additional Assignee List for Change Requests. Here’s what I’m trying to achieve and what I’ve already tried:
Objective:
- When: A Change Request is created or updated, and the Additional Assignee List is modified.
- Who: Send notifications only to the newly added users in the Additional Assignee List.
- Exclude: Previously added users should not receive the notification again.
What I’ve Tried:
1. Notification Configuration:
- Set "Send When" to Record inserted or updated and checked both Insert and Update.
- Set the Condition to Additional Assignee List changes.
- Configured "Who will receive" as Additional Assignee List.
Problem: This sends notifications to all users in the field, including those already present.
2. Advanced Condition in Notification:
- Used the following script to detect newly added users:
if (current.isUpdatedField('additional_assignee_list')) {
var oldAssignees = previous.getValue('additional_assignee_list') || '';
var newAssignees = current.getValue('additional_assignee_list') || '';
var oldAssigneeArray = oldAssignees.split(',');
var newAssigneeArray = newAssignees.split(',');
for (var i = 0; i < newAssigneeArray.length; i++) {
if (oldAssigneeArray.indexOf(newAssigneeArray[i]) === -1) {
return true; // Trigger notification for new users
}
}
}
return false;
Problem: ServiceNow’s Advanced Condition field does not support return or complex logic, causing parse errors.
3. Business Rule with Events:
- Created a Business Rule to compare current and previous values of the Additional Assignee List, identify newly added users, and fire an event:
if (current.isUpdatedField('additional_assignee_list')) {
var oldAssignees = previous.getValue('additional_assignee_list') || '';
var newAssignees = current.getValue('additional_assignee_list') || '';
var oldAssigneeArray = oldAssignees.split(',');
var newAssigneeArray = newAssignees.split(',');
var addedUsers = [];
for (var i = 0; i < newAssigneeArray.length; i++) {
if (oldAssigneeArray.indexOf(newAssigneeArray[i]) === -1) {
addedUsers.push(newAssigneeArray[i]);
}
}
if (addedUsers.length > 0) {
gs.eventQueue('notify.new_assignees', current, addedUsers.join(','), null);
}
}
- Created a Notification triggered by the notify.new_assignees event with Event Parm 1 contains recipient.
4. Filter Condition on Notification:
- Tried setting the Condition to Additional Assignee List changes, but this still sends the notification to all users in the field, not just the new ones.
How can I configure ServiceNow to send notifications only to newly added users in the Additional Assignee List, either using native features or a reliable script-based approach?
I’m doing my best to work through this, but as I’m not a developer, scripting is a bit outside my comfort zone. I’d appreciate any suggestions or examples that could help me get this working!
Thank you in advance for your support!
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 08:25 AM - edited 01-21-2025 08:26 AM
Found the issue. It was with the script.
The script you provided was checking for previous.watch_list and current.watch_list but these fields do not correspond to the additional_assignee_list that I wanted to monitor. So, I've replaced watch_list with additional_assignee_list.
I've also modified the third parameter (emailTo) in gs.eventQueue by adding a comma-separated string instead of passing it as an array. Here is the final script that I used and made it work:
(function executeRule(current, previous /*null when async*/) {
var oldAssigneeList = [];
var newAssigneeList = [];
var emailTo = [];
// Get the previous and current values of Additional Assignee List
if (previous.additional_assignee_list)
oldAssigneeList = previous.additional_assignee_list.split(',');
if (current.additional_assignee_list)
newAssigneeList = current.additional_assignee_list.split(',');
// Find newly added users
if (oldAssigneeList.length === 0) {
emailTo = newAssigneeList; // All current assignees are new if the old list is empty
} else {
for (var i = 0; i < newAssigneeList.length; i++) {
if (oldAssigneeList.indexOf(newAssigneeList[i]) < 0) {
emailTo.push(newAssigneeList[i]); // Add only new assignees
}
}
}
// Trigger the event if there are new users
if (emailTo.length > 0) {
gs.log("Triggering event for new assignees: " + emailTo.join(','));
gs.eventQueue('notify.new_assignees', current, emailTo.join(','), null);
}
})(current, previous);
Thank you for your input and insight in helping me solving this issue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 07:00 AM
ensure Send to event creator is checked on notification.
Also are you sure those recipients have email field populated, not locked out and has notification preference enabled?
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
01-21-2025 07:12 AM
Send to even creator is checked.
The recipients' email field are populated. The notifications are sent when in the Who will receive "Users/Groups in fields" is set to Additional Assignee list (but to everyone, instead of only the new ones) but by removing it, no notifications are sent to anyone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 07:18 AM
Don't set the recipient from Who will receive as we are sending the recipients from eventQueue
I already informed earlier the same
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
01-21-2025 07:20 AM
Yes, I know. That's how I configured it. I was just pointing out that I tested both ways to make sure the recipients' email fields were correctly populated. Otherwise, I have exactly configured as you explained 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 07:20 AM
If you have followed all the steps I shared above and recipients are set correctly and event is processed but no email then did you check Event parm1 contains recipient checkbox
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