Add newly added watchlist member to "TO" address of a notification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 11:16 PM
I have a requirement to send a notification on incident to newly added user of watchlist. the newly added user email should be the to address. How can i achieve this?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 11:23 PM
Hi @Atchutaram,
You can trigger an event via a BR when a new user is added to the watchlist.
Include the 'new' user in the event's parameter and you can use it for the notification's recipient.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 11:34 PM
Hi @James Chun
I have done that it is working for one user, but when we add new user its not working here is the code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 01:19 PM - edited 04-03-2024 01:19 PM
Hi @Atchutaram,
I would advise using the 'after' Business Rule instead of 'before'.
Below is the modified script:
(function executeRule(current, previous /*null when async*/ ) {
var arrayUtil = new ArrayUtil();
var currArr = current.watch_list.split(',');
var prevArr = previous.watch_list.split(',');
//Find difference bewteen current and previous lists
var diffArr = arrayUtil.diff(currArr, prevArr);
//Find 'new' added users only
var newArr = arrayUtil.intersect(currArr, diffArr);
if (newArr.length > 0) {
gs.eventQueue('watchlist_add', current, newArr.join(','));
}
})(current, previous);