Group Members has groups that no longer exist

Robert Campbell
Tera Guru

When I look at the Group Members table, there are groups listed that no longer exist. Is there a way to clean this up?

 

I don't want to go through them one-by-one to find them. I was trying to do a report but if I choose Group Member as the table, I can't choose Groups as a related table because they don't relate "that way". If I choose Groups as the table, I can then choose Group Members as a related table but this is essentially a left join on Group's table. 

26 REPLIES 26

It means, you want to know the group which has been deleted but records exits. 

*************************************************************************************************************
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]

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

Yes. The groups show on the Group Members table but they don't actually exist in the Groups table. Because they show up on the Group Members table, they show up in reports built off the Group Members table so those numbers are incorrect.

AndersBGS
Tera Patron
Tera Patron

Hi @Robert Campbell ,

 

Create a report based on the sys_user_group table:

AndersBGS_0-1703081359790.png

Chose "group members" as the related list conditions

AndersBGS_1-1703081394977.png

Remember to set "equal to 0" in selected table

AndersBGS_2-1703081440339.png

This will give you an overview of the groups that doesn't have any users in the related list. 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

best regards

Anders 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

I use a similar report to show where the groups have no members but in this scenario, I need to find the groups that don't actually exist. There is a record of the group in the Group Members table but that group no longer exists.

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @Robert Campbell ,

 

as per my understanding, it is beacause of when you are deleting groups from sys_user_group table. It is not deleting related record or mybe some another process/flow/script is running in background which is creating this records in your instance. 

But it should delete the all related records for example roles, users sub-groups etc.

As it is not doing that in this case. And you want to clear this type of record for sys_user_grmember table. You can run a fix script for cleanup as follow:

 

// Instead of empty sys_id of group field, please try null, undefined as well. I am not sure about what will work for you.

var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', '');
gr.query();
while(gr.next()){
	gr.deleteMultiple();
}

 

Kindly mark my answer as Correct and helpful based on the Impact.

Regards,

Siddhesh