How to lists all groups with number of group members?

bbf3562
Kilo Guru

As SN administrator, I want to list all queue groups with number of group members in the system, set a field for number of members and order the data by count so that I can find number of members in group. Also I want to be able to set categories of large and small numbers of members if possible.

Where in ServiceNow that I can create that data view and I believe I can use SQL script using "having" clause?

Here is mock example desired to be on list sort on count(number of members),

GJK-QUEUE NAME-IT-SYSTEM(25) <--- 25 is number of members.

1 ACCEPTED SOLUTION

bbf3562
Kilo Guru

I have found a way to be able to sort out list based on number of members is by creating a new field for total number of members.


First, I create a 2 new columns in sys_user_group like Total of Group Member and Total of Active Group Member.



Second, I create a script in Scheduled Job to run and populate data in 2 new columns to show results number of members. Screenshot show below


MembersScript.jpg


Third, I create a report based on group and show list of group name, total of group members, and total of active group members. Now I can sort out the numbers. Here screenshot example,


results.jpg


View solution in original post

5 REPLIES 5

gyedwab
Mega Guru

Hi Bradley,



You can sort of do this using a pre-built join, the Groupmember [sys_user_grmember] table.



The UI of ServiceNow reporting is a little constrained, but here's an example as a pivot:


Screenshot 2017-01-12 12.37.36.png


Or as a grouped list:


Screenshot 2017-01-12 12.39.40.png


In both cases, you can't really sort based on the number of group members, or group them by number of members. You can do that with Explore Analytics.



Here's an Explore pivot grouped from largest to smallest groups:


Screenshot 2017-01-12 12.41.58.png



And here's the # of groups grouped by how many members the groups have (there are 4 groups with 8+ members, for example):



Screenshot 2017-01-12 12.45.07.png



Explore Analytics can also do on-the-fly joining without requiring SQL, although I don't think you'd need it here.


So there is no way to sort out by number of members using SQL query in ServiceNow or do alternative way with plugin without paying monthly like Explore Analytics?


ServiceNow doesn't allow SQL querying. Through script, you could use the GlideAggregate API to query:



GlideAggregate - ServiceNow Wiki



But there isn't a UI for displaying it that I'm aware of, unless there's something I've missed.


Couldn't you add a member count field to the group table and a business rule on the group membership table that runs on insert and delete and sets the field to the count?


You'd have to run a fix script to initially get the numbers, but it should stay green after that.