
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 05:00 AM
Good Morning Experts,
We have a requirement to add a new role to an existing role. The issue is the existing role already has 130K+ users inheriting it, so when attempting to add the new role via UI it updates 10K users at a time and then times out. The role then doesn't appear in the 'contains role' list for the existing role (I assume because it wasn't successfully applied to all users).
I'm thinking this might be easier to do via background script. Does anyone have a script for such a task?
Thanks in advance,
James B
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 05:25 AM
var addRole = new GlideRecord('sys_user_role_contains');
addRole.initialize();
addRole.role = 'sys_id of parent role';
addRole.contains = 'sys_id of new role';
addRole.insert();
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 05:25 AM
var addRole = new GlideRecord('sys_user_role_contains');
addRole.initialize();
addRole.role = 'sys_id of parent role';
addRole.contains = 'sys_id of new role';
addRole.insert();
Raghav
MVP 2023

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 07:28 AM
Worked perfectly. Thank you so much for your help.
James B.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 06:42 AM
Along the same idea, can I get help adding a custom role to ALL users? The role is pm_user and needs added to all users.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 03:15 AM
Hi @RaghavSh ,
How can I give a role to all members of a group by script in one go?
If you could provide a script for this, it would be helpful for me.
Thanks,
Amol