Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 08:44 PM
Hi @Vamshi_ch123 ,
You can't delete/remove roles which are inherited from the groups.
var userRole = new GlideRecord('sys_user_has_role');
userRole.addEncodedQuery("sys_updated_onON2024-05-29@javascript:gs.dateGenerate('2024-05-29','start')@javascript:gs.dateGenerate('2024-05-29','end')^inherited=False");
userRole.query();
userRole.deleteMultiple();Here in encoded query I have added a condition to check are not inherited. This will remove user roles which are directly assigned to them.
However, if you want to remove the roles which are inherited (from group) you need to remove the user from that group.
If my answer helped you in any way, please mark it as helpful or correct.