- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 05:43 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 07:23 AM
Hi @smithro ,
Correct. The first response I added will provide Groups that have Zero Group Members associated to them.
Thank you,
Josh Pirozzi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 06:06 AM - edited 11-30-2023 06:17 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 06:11 AM
Hi @smithro
Create report
Type = Score
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 06:14 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 07:10 AM
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]
****************************************************************************************************************