Notification to Event parm 2 not sending notfication to watch list - event is created by Incident Record Producer

Chris Dea1
Tera Contributor

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). 

find_real_file.png

 

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).

find_real_file.png

 

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

 

 

8 REPLIES 8

AnirudhKumar
Mega Sage
Mega Sage

Hello Chris,

I have to declare you have been very thorough in your analysis 🙂

Your configurations are all good, could you check the below points too?

- Is the watchlist user part of the assignment group? (If so, system may not send the notification to the watchlist user)

- Is the users email settings enabled? (this is a silly point, but do check the user record if active is true, email is present, and email sending is enabled)

Hi AnirudhKumar, I am been doing my best to debug but still cannot find the source of the issue :(.  -User being added to watch list is not a member of assignment group.

-And the user is active and has email address on user.

Note, since I am working in our Dev instance, email sending is not enabled but I believe I should see an entry in System Log > Emails for  notification to the user on watch list with "send-ready" -- I do see entry for the assignment_group from Record Producer (in this case Systems_Group which is Event parm 1).  

 

At this point I am wondering is there some issue with using Event parm 2 to add user to watch list?

 

Thanks for trying to help!

Chris Dea1
Tera Contributor

Ok, this gets more strange now.  I was experimenting with changing the line in the script that creates the event.  For the heck of it I changed the Event parm 1 to the string 'Systems_Group' and now a notification sends to the user on watch list (Event parm 2).    But that changes the problem now... now the assignment_group (Event parm 1) is not getting send notification!

gs.eventQueue('new.data.breach.record',current,'Systems_Group',current.watch_list);

 

This is what the notification in the log looks like after making this change.  I have no idea why that would make the notification send to watch list now.  I still need help figuring this out because now the assignment group will not get notification :)....

 

-Chris

 

Hi Chris,

Couple of comments.

a. In the first case, all recipients (parm 1 and parm 2) will be merged and sent in one single email. So wanted to check if you looked for the watch list user's email id in the notification that was sent to the group. Looking at your thoroughness, I am certain you would have but wanted to cross check.

b. In the second case, no notification was sent to group as you have set the group name. Please change it to group sys_id and try.

Thanks,

Arav