Business rule to remove inactive users from watchlists

Jesus Nava
Tera Guru

Hello experts, please I need your help, I'm creating a BR that removes inactive users from a watchlist, this is what I have and I found out something, if the watchlist has mre than one user, this does not work, this works when there is just a single user =( what do I need to modify as well?

 

JesusNava_0-1677701137382.png

This is working when I have the user just in "Watch list", how can I add another condition to check another field called: Worknotes list

JesusNava_2-1677701484584.png

 

how can I add another condition to remove the user from Worknotes watch list too? I tried:

JesusNava_1-1677701276566.png

but it is not working, what am I doing wrong? 

I need to add 2 more custom watchlists, so I will need to add a total of 4 conditions to remove the inactive users from those 4 watch lists once the other 2 are created, could you please guide me?

Thank you

 

1 ACCEPTED SOLUTION

Hi,

Thanks. So you'd need to take the current watch_list and make it into an array and if they're found, remove them, and then set the watch_list to the final value (could be none or could be all the other names still there but the inactive user is removed).

So something like:

 

 

var array = tsks.watch_list.toString().split(',');
if (array.indexOf(current.getValue('sys_id')) > -1) {
var index = array.indexOf(current.getValue('sys_id'));
array.splice(index, 1);
tsks.watch_list = array;
}
var array2 = tsks.work_notes_list.toString().split(',');
if (array2.indexOf(current.getValue('sys_id')) > -1) {
var index2 = array2.indexOf(current.getValue('sys_id'));
array2.splice(index2, 1);
tsks.work_notes_list = array2;
}
tsks.update();

 

 

The above is an example to add to your code after the while(tsks.next()) { line.

Please follow similar format array3, array4, etc. as you need. There are other ways to do this, but I've provided one example. Thanks!

View solution in original post

5 REPLIES 5

Thank you Allen!

Warm Regards