Report On Group Member Count

smithro
Tera Guru

What is the easiest way to build a query that tells me how many active members are in a Group?  We have hundreds of groups, so this would be a helpful admin tool.  I think ideally I'd like an integer field on the group table that counts number of active members.  From there I could add the field to the group list view for sorting.  The field would also need to display a zero for those groups with no active members.  

1 ACCEPTED SOLUTION

Hi @smithro , 

Correct. The first response I added will provide Groups that have Zero Group Members associated to them.

Thank you,

Josh Pirozzi

View solution in original post

11 REPLIES 11

Kushal09
Tera Guru

This snippet will help you get the number of people in a group of your choice. You can use this in a business rule to update the field of your choice on the form.

 

 

 

var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group.name', '<nameOfGroup>');
gr.query();
var number = gr.getRowCount();

 

 

 

Please mark my answer as helpful/solution if I answered your query
Kushal Bahirwani
Technical Consultant

 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @smithro 

 

Create report 

Type = Score

 

LearnNGrowAtul_0-1701353496612.png

No script is required. 

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

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

That's not really what i'm looking to do.  I am looking for a way to quickly identify the groups that have zero members.

Hi @smithro 

 

In that case you can go with Pivot table as suggested by @Josh Pirozzi 

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

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