The CreatorCon Call for Content is officially open! Get started here.

Delete orphan records from sys_user_has_role table

gee
Tera Guru

Hi Team,

I have an issue with deleting orphan records from sys_user_has_role table.

Tried with fix script to delete these records using GlideRecord, failed.

Delete button is disabled, even though schema level deletion is enable.

Also dried to deleted the user and imported the same user record using XML (user record export). Still role definitions are there!

Is there any method to delete these records from the above table?

Any suggestion please?

Platform is on Helsinki Patch 8.

Thanks & Regards,

Gee Abraham

1 ACCEPTED SOLUTION

gee
Tera Guru

Hi All,


This issue has been resolved by installing the following plugin.


Contextual Security: Role Management Enhancements (com.glide.role_management.inh_count)



Many thanks for your efforts to resolve this issue.



Best Regards,


Gee


View solution in original post

29 REPLIES 29

gee
Tera Guru

Hi Rajshekhar,


We have user_name (User ID)   and email id values are the same.



I am getting the correct user record and it contains 8 orphan roles. Query and scripts are OK, but not deleting it from the sys_user_has_role table.


Strange issue, unable to understand the reason!



Thanks,


Gee


Hi Gee,



I have understood the issue, whereas I am facing the similar situation for only one user in my personal Dev instance.
But when I checked roles of the user in the Roles related list from the user record, I found there were no roles showing in the Available slush bucket of the roles.



e.g.



find_real_file.png



find_real_file.png find_real_file.png



But for other users, the script is working fine for me.



Could you please check the issue, because I am not getting the reason here at this go...



Regards,


Rajshekhar Paul


gee
Tera Guru

Hi Rajshekhar,


Yes, same issue. Roles are listed on the related list, but on the edit/slush-bucket none of the role listed (empty).


Thanks & Regards,


Gee


FYI


User Role Edit window.GIF


Hi Gee,



This script is working fine for deletion of roles from the users. But the User's those are associated with any groups having roles, will not get deleted from there.


For those you may need to find some alternative way out. But one thing to say, what I understood from the subject line of your query is, you wanted to delete the orphan records from the sys_user_has_role table. So, my scripts serves that purpose completely, and the rest of the roles that are remaining is not orphaned but are actually getting inherited from groups the user is associated.



I hope this will help and clarify you.



Please hit like or helpful based on impact.



Thanks,


Rajshekhar Paul