- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-14-2022 11:52 PM
i've tried this but its not working as we can't delete the record even from table ui level
also tried to switch to security admin and tried to delete it its not working
basically we can't delete this record
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('user','sys_id of the user');
gr.query();
while(gr.next()){
gr.deleteRecord();
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-15-2022 12:02 AM
var userRole = new GlideRecord('sys_user_has_role');
If my response helps please mark as correct/helpful. š
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-14-2022 11:54 PM
Hello Ravi,
Mostly the user role are driven by the group to which the user is added you can first try to remove user form the group and then see if still roles are present and then try to remove the roles.
Please mark my answer correct/ helpful.
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-14-2022 11:56 PM
So you can't delete any role from this user, or does he only has one role left? Is the role inherited? I had this issue once when an OOB role was included in a custom role and that custom role got deleted. It was impossible to delete the role from the user (scripting/ui). We had to log a Hi case and it was done on database level (asked for the script, but didn't get it). You could try that.
If my answer helped you in any way, please then mark it as helpful. If it resolved the issue, please mark it as correct. This way others will find it in the solved queue and helps them on similar queries.
Mark
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-14-2022 11:58 PM
Hi,
I would suggest to check role is inherited or not? or directly assigned to user. based on that you have to write a scripts.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-15-2022 12:02 AM
var userRole = new GlideRecord('sys_user_has_role');
If my response helps please mark as correct/helpful. š