Notification to Event parm 2 not sending notfication to watch list - event is created by Incident Record Producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2022 12:35 PM
Hi All,
I hope someone can help save me from pulling my hair out :)! I am modifying am existing record producer that a previous sys admin created to generate incidents for Data Breaches. The change is that I needs to do two things: 1) automatically add a user to the watch list, and 2) trigger a notification to that person added to the watch list for those Data Breach Incidents. Down below is the script I have modified...
At top, I modified the script to add a variable with the user's sys_id, and lower down in script I set current.watch_list to that variable. At the very bottom of script, I also added an event which is used to trigger a new Data Breach notification ( from event named new.data.breach.record ).
Things seem to partly work...the user (wl_user1) is added to the watch list on a incident record created by the record producer and modified script. However the one thing I cannot get working is the notification to the user on watch list (Event parm 2 of event).... For the life of me I cannot see what the notification is not sending for the watch list! The record producer (with modified script) adds user to watch list, appears to create the event, and event seems to trigger notification partly... The assignment_group (Systems_Group) is set on Event parm 1 for the event is being sent a notification...but watch_list on Event parm 2 is not being sent notification.
Note I say "sent", but I am working on Dev instance and sending emails is disabled. But I should still see a log entry for the person on watch list with Type of "send-ready", right?
var wl_user1 = '5969b560db211c102a6d531dd3961921'; // sys_id of user to add to watch list
current.assignment_group = gs.getProperty("systems.group");
current.assigned_to = gs.getProperty("data.breach.assignedto");
current.short_description = "Data Breach - "+producer.type_of_breach;
current.category = 'network';
//Add caller_id of user submitting record
current.caller_id = current.u_requested_by;
var variableInfo = '';
for(var v in producer){
if (v.startsWith("IO")) { //only variables
var question = new GlideRecord('item_option_new');
question.get(v.substring(2)); // Querying by sys_id to determine question text
if(producer[v])
variableInfo += question.question_text + ": " + producer[v].getDisplayValue() + "\n"; // Set key:value pair to variable
}
}
//Add user to watch list
current.watch_list = wl_user1;
current.work_notes = variableInfo;
gs.log('CD LOG -- watch_list: '+current.watch_list);
//Add event for notification for new Data Breach records
gs.eventQueue('new.data.breach.record',current,current.assignment_group,current.watch_list);
This is a screenshot showing the entry in System Log, that seems to indicate notification is being triggered fine to user on the watch list from the (new.data.breach.record event)...Note the sys_id shown is the sys_id of the user added to watch list on the record producer script (Event parm 2).
And here's a screenshot of the entry from System Logs > Emails for the group called Systems_Group which IS getting notification (from Event parm 1 of the new.data.breach.record event created by record producer script).
Based on everything I see, it seems like the user added to watch list should be getting notification but I have tested dozens of times and I do not see any entry in System Logs > Emails to indicate notification for the user on watch list. What's weird is the System Log has an entry showing a Notification was triggered to the user on the watch list (sys_id of 5969b560db211c102a6d531dd3961921). Note both "Event parm 1 contains recipient" and "Event parm 2 contains recipient" are selected on the "Who will receive" tab of my new notification.
If anyone can help point me to a solution I would greatly appreciate it. I am new to scripting in ServiceNow so if I am going in the wrong direction to get the notification sent to the person added to the watch list, please let me know.
Thanks,
Chris

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2022 09:07 PM
I don't know if this would help could you please help us understand the notification configuration ? is there any email script that you are using ? as it would be better if the email address is extracted from the user sys_ids that are sent on the param2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 07:09 AM
Thank you for trying to help Arav and Rohit! I did some debugging with gs.log statement on the record producer script and the current.watch_list is getting sys_id of the user as desired.
The sys_id of the assignment group (Event parm 1) is getting assigned by script on the record producer (assignment group from systems.group system property). And as odd as it sounds, I can only get the notification to watch list (Event parm 2 on the event from record producer) to work when I basically break the Event parm 1 and set it to the display name of "Systems_Group" -- even though I know that will break notification to the assignment_group. Basically if the record producer results in event with Event parm 1 with sys_id of the group and the Event parm 2 of watch_list user, only assignment group gets notification. However, if I "break" Event parm 1 and set it to have display name of assignment group for Event parm 1, then the notification to Event parm 2 (watch_list) works...
My best guess is that there is either a bug or there's a business rule that is firing off a conflicting event that causes this weird problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 09:24 PM
Hi Chris,
It's difficult to say what's going on but please try this workaround to get things moving.
var notifArray = []; //create an array;
//push both assignment group and watch list sys_ids to the array
notifArray.push(current.assignment_group.toString());
notifArray.push(current.watch_list.toString());
//Trigger the event as follows
gs.eventQueue('new.data.breach.record', current, notifArray.join(), '');
Hope this works.
Thanks,
Arav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 07:46 AM
Sorry for the delay in getting back to you Arav. Unfortunately even after using your workaround to create an array for the notification event it did not work completely. When I used the modified script only the assignment_group (Event parm 1) would get notification and watch_list (Event parm 2) would stop getting notification. For now I will use the workaround of having notification send to Event parm 2 (watch_list) and have a separate notification to send to assignment_group based off keywords on record created. Thanks again for your help!