- 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
ā07-28-2022 05:57 AM
Hi,
You can try with below fix script.
var gr = new GlideRecord("sys_user_group");
gr.addQuery("role", "sysid of existing role"); // give old role sysid
gr.query();
while(gr.next()) {
var gr1 = new GlideRecord("sys_group_has_role");
gr1.initialize();
gr1.group = gr.group;
gr1.role = "sysid of new role"; //give sysid of your new role
gr1.insert();
gr.deleteRecord();
}
Mark as correct and helpful if it solved your query.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-29-2022 03:26 AM
Feel free to reach out if you have further questions or else you can mark an answer as correct and helpful to close the thread so that it benefits future visitors also.
Regards,
Sumanth
- 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
ā07-31-2022 10:43 PM
Did you mistakenly marked your own response as correct?
The script I shared already had the correct solution.
Would you mind marking appropriate response as correct?
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader