- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2022 05:39 AM
Hi Team,
Please let me know how to acheive this.
i have around 120 groups that have workspace_user role.
Now, I want to replace workspace_user role to agent_workspace_user role in all the groups.
i tried with transform map with Group set as colasee but sys_group_has_role record is not updating.
can anyone please provide a sample fix script to acheive this.
Thanks in advance.
Hari kishan.
Solved! Go to Solution.
- Labels:
-
Agent Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2022 10:38 PM
Hi Sumanth,
Just small Correction to the code..
Need to replace sys_user_group to sys_group_has_role in line 1.
Thank you,
Hari Kishan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 12:25 AM
Hi Ankur,
Both are working but, your solution is time consumig, as i need to put around 120 groups in the Var Str(need to open each group record and copy name of the group and past it in the string). it won't need it in my correct response.
That's why i didn't mark your answer as complete.
Thank you,
Hari Kishan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 01:18 AM
Glad that you made it to work.
Looks like you marked your own answer as correct 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2022 03:39 AM
Hi,
There is no script required; you can use Update Selected Records on List of sys_group_has_role table and update the role field to new role; It would update for all those groups.
Edit multiple records in a list using an editing form
OR
If you still require fix script then check this
I assume you must be having the names of those 120 groups or sysIds
Update as this
updateRoles();
function updateRoles(){
try{
var str = 'Group 1,Group2,Group3'; // give here
var gr = new GlideRecord("sys_group_has_role");
gr.addQuery("group.name", "IN", str);
gr.addQuery("role.name", "workspace_user");
gr.query();
while(gr.next()) {
gr.setDisplayValue('role','agent_workspace_user');
gr.update();
}
}
catch(ex){
gs.info(ex);
}
}
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
‎07-29-2022 11:22 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader