- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2023 12:54 PM
I need to move about 600 users who has an itil role to a new group. What is the best way to do so?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2023 01:09 PM
Hello @nebiata ,
You can use fix script or background script.
For reference, you can use below script and update the sys_id of itil role and group at the respective lines.
var gr = new GlideRecord('sys_user_has_role');
gr.addEncodedQuery('role=282bf1fac6112285017366cb5f867469');//sys_id of the itil role
gr.query();
gs.info(gr.getRowCount());
while(gr.next()){
var newGroup = new GlideRecord('sys_user_grmember');
newGroup.initialize();
newGroup.user = gr.user;
newGroup.group = '019ad92ec7230010393d265c95c260dd' ; // sys_id of new group
newGroup.insert();
}
Please Mark my answer Helpful & Accepted if I have answered your question.
Thanks,
Alka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2023 01:09 PM
Hello @nebiata ,
You can use fix script or background script.
For reference, you can use below script and update the sys_id of itil role and group at the respective lines.
var gr = new GlideRecord('sys_user_has_role');
gr.addEncodedQuery('role=282bf1fac6112285017366cb5f867469');//sys_id of the itil role
gr.query();
gs.info(gr.getRowCount());
while(gr.next()){
var newGroup = new GlideRecord('sys_user_grmember');
newGroup.initialize();
newGroup.user = gr.user;
newGroup.group = '019ad92ec7230010393d265c95c260dd' ; // sys_id of new group
newGroup.insert();
}
Please Mark my answer Helpful & Accepted if I have answered your question.
Thanks,
Alka