- 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-15-2022 12:07 AM
Hi,
basically you are deleting all roles for that user via script?
Is that script not working fine?
Script looks fine to me
Any Before delete BR on sys_user_has_role is restricting the delete?
Are you running this script in scoped app?
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
ā09-15-2022 12:46 AM
it worked but i used addEncodedQuery() and yess here i was removing all the roles belong to that specific user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-15-2022 01:56 AM
Thanks for informing.
But the response you marked as correct doesn't relate to your question.
the answer marked as correct won't work for your requirement.
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader