not able to remove role

sunil maddheshi
Tera Guru

Hi There is a user which we deactivated and removed the user from all groups it is associated, but there is two we can see which is not getting removed, when we go to slush bucket we can see empty also we tried to delete using BG script but still it is not getting deleted, please see the screenshot:
Annotation 2025-03-11 221800.png
This is BG script:

var grSUHR = new GlideRecord('sys_user_has_role');
grSUHR.addEncodedQuery("user=ce309d321b6ba950602654a3604bcb4f");
grSUHR.setLimit(2);
grSUHR.query();
gs.info(grSUHR.getRowCount()); // getting row count as 2
while (grSUHR.next()) {
gs.info("Hi");   // getting Hi
grSUHR.deleteMultiple();
grSUHR.update();
}

1 ACCEPTED SOLUTION

Viraj Hudlikar
Giga Sage

Hello @sunil maddheshi 

 

Did you check if role is inherited from any group, as per screenshot shared by you did you click on Role Inheritance Map column value which will let you from where this role is inherited over user profile.

 

This situation can occur if anything has left orphan relationship creation in user profile or over the group where roles are added. 

You can also have a look on this thread - Solved: Roles Not Removing from User - ServiceNow Community

If above thread doesn't helps, then I would recommend creating a HI Case and get this cleared out where they will run some cleanup script, and you can get rid of such role showcase under user profiles.

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

View solution in original post

4 REPLIES 4

Viraj Hudlikar
Giga Sage

Hello @sunil maddheshi 

 

Did you check if role is inherited from any group, as per screenshot shared by you did you click on Role Inheritance Map column value which will let you from where this role is inherited over user profile.

 

This situation can occur if anything has left orphan relationship creation in user profile or over the group where roles are added. 

You can also have a look on this thread - Solved: Roles Not Removing from User - ServiceNow Community

If above thread doesn't helps, then I would recommend creating a HI Case and get this cleared out where they will run some cleanup script, and you can get rid of such role showcase under user profiles.

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

Rohit  Singh
Mega Sage

Hi @sunil maddheshi ,

 

We have faced similar issue in past in prod instance. Please raise a case with ServiceNow to fix it.

 

If my response helped, please mark hit the Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Rohit

Shivalika
Mega Sage

Hello @sunil maddheshi 

 

I can see the field value of "inherited" as true. Please change it to "false" first and then try to remove this roles. We have removed bulk orphan roles in the same way. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway,

 

Regards,

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @sunil maddheshi 

When a user is deactivated and removed from a group, what specific issue are you facing? Why are you focusing on role removal?

Roles can be inherited for various reasons, but I’m not quite understanding the concern here—if the user is already deactivated, they shouldn’t be able to access the system. Could you clarify what problem you're encountering?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************