How to add or remove an user from list collector field.

sinu2
Tera Expert

Hi Team ,

 

I have an requirement, I have a scheduled report, and in that a user field list collector type present.

And i have a manager field refers to user table in the sys_user_group table. If "XYZ" group has changed the manager in that record, then we need to check the removed user in the manager fiels wheather exist in the list collector scheduled report or not. if yes the user still present means we need to remove and we need to add newly added manager in the list collector field. 

 

Businnes rule trigger condition on group table

 

When ever manager changes this BR will trigger 

sinu2_0-1694421422010.png

 

Scheduled report:::::::::::::::::::::::::::::::

sinu2_1-1694421591723.png

 

10 REPLIES 10

SimonL898794821
Mega Sage

Maybe you should add all relevant groups instead of picking individual users, that should send the notification to the current manager.

Nope. May be you did not get my question clearly. I am just asking how to check existing members in the list collector to remove the user that has been changed from the group table manager field to add newly added group manager in to the list collector

Vengateshwaran
Mega Guru

Hi @sinu2 ,

You can write a business rule in 'sys_user_group' with the script below

var gr = new GlideRecord('sysauto_report');
gr.addQuery('sys_id','');
gr.query();
if(gr.next()){
var list = gr.user_list;
list = list.split(',');
var index = list.indexOf(previous.manager);
if(index =>0 ){
   list.splice(index,1);
}
list.push(current.manager.toString());
gr.update();
}

I have made some changes for clarity, 
var gr = new GlideRecord('sysauto_report');
gr.addQuery('sys_id','*********');
gr.query();
if(gr.next()){
var list = gr.user_list;
list = list.split(',');
var index = list.indexOf(previous.manager);
if(index =>0 ){
   list.splice(index,1);
}
list.push(current.manager.toString());
gr.user_list = list;
gr.update();
}
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!