Add user to watchlist with business rule

Mike D1
Giga Guru

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

find_real_file.pngfind_real_file.pngfind_real_file.png

1 ACCEPTED SOLUTION

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;
});
}

View solution in original post

6 REPLIES 6

Jan Cernocky
Tera Guru

Hi Mike,

you're assigning to the watchlist property, not the variable.

So it should be current.watch_list = watchers;

Hi Jan

Thanks for the reply.

Apologies that was an error. I have changed this to the watcher variable, however it still is not adding the user to the watchlist.

I have the correct sys_id of the user in the system property. Any further ideas?

find_real_file.png

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. 

 

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.