sys_user_has_role table contains empty roles

Mayuri1711
Tera Contributor

One or more (empty) Roles in User profile and are inherited, unable to remove /delete.

6 REPLIES 6

shyamkumar VK
Kilo Patron

@Mayuri1711 ,

Include this to fix script and run in lower instance

var gr = new GlideRecord('sys_user_has_role');
gr.addEncodedQuery(INSERT YOUR QUERY HERE);
gr.query();

while(gr.next()){
  gr.inherited = false;
  gr.setWorkflow(false);
  gr.autoSysFields(false);
  gr.update();
}
Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Can you share an example? And please be more specific with what you exactly mean with unable to remove/delete.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

swathisarang98
Giga Sage
Giga Sage

Hi @Mayuri1711 ,

 

There is a Servicenow support article related to this please refer the below,

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0781684 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

AJ-TechTrek
Giga Sage
Giga Sage

Hi @Mayuri1711 ,

 

Can you please share the any example or screenshot as that table having all roles details .

 

You can refer the below.

 

https://www.servicenow.com/community/developer-forum/remove-empty-user-from-sys-user-has-role/m-p/18...

 

https://www.servicenow.com/community/now-platform-forum/empty-users-in-user-roles/m-p/1097189

 

Please appreciate the efforts of community contributors by marking appropriate response as Mark my Answer Helpful or Accept Solution this may help other community users to follow correct solution in future.

 

Thanks

AJ

Linkedin Profile:- https://www.linkedin.com/in/ajay-kumar-66a91385/

ServiceNow Community Rising Star 2024