- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 02:24 AM
In the example below, there are 200 members in Group A and 180 members in Group B. How would you best go about moving all the members from Group B to Group A? Resulting in 380 members in Group A and no members in Group B.
thx, Parker
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 09:33 AM
Not a very sophisticated solution, but it's super-quick and it works:
- Go to Group B, set the related list for Group Members to only show the User ID column
- Select the whole list of User id's by dragging the mouse down, and copy (ctrl+c)
- Go to the Group A related list for Group Members, click the blue Edit button
- In the slushbucket form, add filter "User ID is one of" and paste the list of User IDs in the box, run the filter
- Now the first 100 users (if you haven't increased that limit) show up in the left slush bucket window. Move them to the right window.
- Run the filter again to get the next 100 users, move them to the right. Repeat until they are all added, and Save.
- Finally, go back to the slushbucket form for Group B and remove the users from that group.
cheers, hope that helps /Tommy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 02:30 AM
Hello
Please run the below code in background script.
var grp = new GlideAggregate("sys_user_grmember");
grp.addAggregate("COUNT");
grp.addEncodedQuery('---------------------'); // Your query condition
grp.groupBy("user");
grp.query();
while (grp.next())
{
//gs.print(grp.user.name);
var rec1 = new GlideRecord('sys_user_grmember');
rec1.initialize();
rec1.user = grp.user;
rec1.group.setDisplayValue('------------'); // New group name
rec1.insert();
}
var pr= new GlideRecord('sys_group_has_role');
pr.addEncodedQuery('------------------') //; Query condition to delete records
pr.query();
while(pr.next())
{
pr.deleteMultiple();
}
Cheers..!
Happy learning:)
Tushar
Cheers..!

Happy Learning:)

Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 02:31 AM
Hi phenkry,
I'll create a fix script for this and run it as need it. I let some code for achieving this:
var grGroupA = new GlideRecord('sys_user_grmember');
grGroupA.addEncodedQuery('group=' + sysIDGroupA);
grGroupA.query();
while(grGroupA.next()) {
// Add user in group B
grGroupB = new GlideRecord'sys_user_grmember');
grGroupB.initialize();
grGroupB.setValue('group', groupBSysID);
grGroupB.setValue('user', grGroupA.user);
grGroupB.insert();
//Remove record from group A, check first if all Group A members are moved to Group B
grGroupA.deleteRecord();
}
If it was helpful, please give positive feedback.
Thanks,
☆ Community Rising Star 22, 23 & 24 ☆
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 02:49 AM
Easy approach which can be re-used later on
1) create data source and excel file
2) Have 3 columns like this
3) create transform map on sys_user_grmember table, 2 field maps and use onAfter transform script to delete that user from old group
This solution can be re-used later on; you just need to do this
1) go to sys_user_grmember table and filter with Group B and your users and export it
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 02:55 AM
Hi,
Kind of the same solution, but instead using Flow designer, which would require no coding at all.
Trigger on the Flow should be Once, at the date/time of your choice.
Steps 6-7 are optional if you want to perform some logging if a user already is part of group B.
Also, didn't include steps to delete the user from groupmembership A, but it can easily be added if necessary.