Unable to remove Inherited roles from user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2019 12:23 AM
Hi,
I need help in inherited roles.How to remove inherited roles for 50 users.
Thanks,
Pihu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 02:21 AM
I have tried but no use.Not able to delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 05:07 AM
Hello,
You should be able to do this in a background script.
But since it is inherited that stops you, you have to do it in two steps with an update to the record first.
Go to table: "sys_user_has_role" (sys_user_has_role.list in the filter navigator), filter out the users this applies to.
Right click on your filter and select, "Copy query".
Go to Background Script (Application Navigator: System Definition -> Scripts - Background).
In the parenthesis after "addEncodedQuery", insert the query you copied into the table. And execute the script.
I recommend that you do this twice, where the first time is a verification that you receive the correct data.
Test run :
var gr = new GlideRecord("sys_user_has_role");
gr.addEncodedQuery("your copied query");
gr.query();
gs.print("Count : " + gr.getRowCount());
while(gr.next()){
gs.print("User : " + gr.getDisplayValue("user") + " Role : " + gr.getDisplayValue("role"));
}
Execution :
var gr = new GlideRecord("sys_user_has_role");
gr.addEncodedQuery("your copied query");
gr.query();
while(gr.next()){
gr.inherited = false;
gr.update();
gr.deleteRecord();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2019 07:20 AM
Thank you for the reply i will try this and l ll let you know if this works

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 01:13 PM
I was missing the "inherited = false" component and could not figure out why it was working. Appreciate the code snippet example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 12:46 PM
As a side note, you need to Elevate Roles to do this.