How to notify a user when they have been added to the watch list

Eric K3
Kilo Guru

OOB, when a user is added to the watch list, they do not receive a notification. So, they are not aware of anything until someone updates the incident.

How would I immediately notify a user when they are added to the watch list?

I do not want to do a notification where the condition is "Watch list changes" because that would send out the message 12 times if 12 different people are added at 12 different times.

8 REPLIES 8

Michael Fry1
Kilo Patron

Possible solution here but that's really difficult: Re: Did you ever find a way to


acirovic1
Giga Expert

You'll need to compare the previous value with the current value of the watch list collector to be able to determine what changed. Not that difficult to do, the list collector is just a comma separated list of sys_ids which can be easily converted to array. Then it just comes down to comparing arrays.


Liked Aleks' response... this is how I would've handled it too, and you really only need to process the current value as an array.   You can use an indexOf() method on the previous CSV string value for each item in the current array, and fire an event for any unmatched value (i.e., that's new).   Then just setup a notification to respond to that event.




You can place this script in an Insert/Update business rule for whatever kind of task to raise an event when a user gets added to the watchlist...



var arrCurrList = current.watch_list.split(",");


var prevList = previous.watch_list.toString();


for(var i = 0;i < arrCurrList.length;i++){


if(prevList.indexOf(arrCurrList[i]) == -1){


gs.eventQueue("task.add_to_watchlist", current, arrCurrList[i])


}


}




You'll be passing the user's sys_id as eventparm1 to your notification, along with the current task record for reference.




Thanks,


-Brian


This is nice and efficient implementation. If you want to also notify users when they're removed from a watch list, it might be more efficient to do it with array matching.