- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2022 01:29 PM
Hi
I am trying to add a user to a watchlist when record is inserted using a business rule, however it doesn't seem to add the user even though the conditions meet. There are some other business rules, which are adding other users, but this needs to be a separate business rule for this use case. If someone could help me see why it is not working that would be greatly appreciated.
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2022 08:16 PM
Hi Jan
I was able to make this work by replicating another script.
var appendWatchlist = gs.getProperty('sn_hr_le.namChecklist');
var toInsert = current.watch_list.toString() + "," + appendWatchlist;
current.watch_list = removeDuplicatesNAM(toInsert.split(',')).toString();
function removeDuplicatesNAM(data){
return data.filter(function(value,index){
return data.indexOf(value) === index;
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2022 01:39 PM
Hi Mike,
you're assigning to the watchlist property, not the variable.
So it should be current.watch_list = watchers;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2022 04:16 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2022 11:08 PM
Hi Mike,
one more thing - watchers is variable, so no quotes.
If it still doesn't work try to add some gs.log to the beginning to the script.
Then you will see whether the issue is in the condition or the rule is really triggering.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 04:27 PM
Ah yes, sorry silly error.
I logged the sysid from the watchers variable, and it is the user I am expecting. I also removed any conditions.
There is another business rule another developer has implemented which adds some users for other conditions, when I disable this rule it adds my user. It seems for some reason it is unable to append when there is existing users in the watchlist.