The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Add users to multiple groups

david_hreben
Giga Expert

Hello,

I am trying to add a user that was inserted to a group (Let's say "A"), to 3 other groups (Let's say B,C,D). So whenever a user is added to group "A", that user should automatically be added to groups "B,C, and D". So far I came out with the script to add a user to a single group but I cannot accomplish to add the same user to the other 3. Have anyone done such script? Do you have any recommendations? Thanks!

2 REPLIES 2

randrews
Tera Guru

add the group to the other groups.. so   group a would be a member of groups b and c


Mike Allen
Mega Sage

After insert BR on sys_user_grmember


Condition: group = <group_sysid>



var group = new GlideRecord('sys_user_group');


group.addQuery('sys_id', 'IN', '<sysid1>, <sysid2>, <sysid3>');


group.query();


while(group.next()){


        var usgr = new GlideRecord('sys_user_grmember');


        usgr.initialize();


        usgr.user = current.user;


        usgr.group = group;


        usgr.insert();


}



Or something like that.   Play around with it and you'll get it.