- 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-17-2022 10:00 PM
Hi Mike,
two more things come to my mind
a. Try to adjust the BR order, if both are with same order value, this may possibly causing conflicts. By having different orders you manage they run one after each other.
b. Make sure there are not any white spaces in the value or in the sys property. Just in case.
I tried your script construction and it works for both cases when the field is empty or when there is already someone.
- 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;
});
}