Identify the groups with just one member

LK11
Mega Expert

At the moment some of the approval groups have just one member in the group.   I have to identify those groups so that we can add additional members.   How can I find the gorups with just one member?

Thanks

1 ACCEPTED SOLUTION

Patrick Schult2
Giga Guru

You can use a report (or list V3) to query for groups that have exactly 1 group member. See screenshot for an example.



If you don't have list v3 or the Istanbul+ report builder enabled, you will need to write a script. The script would query for all groups, then for each group, get the count of the group members. If the count of the group members is exactly 1, then you would write it to the log or do something else with it.


Groups with 1 member.png


List v3 groups.png


View solution in original post

9 REPLIES 9

Patrick Schult2
Giga Guru

You can use a report (or list V3) to query for groups that have exactly 1 group member. See screenshot for an example.



If you don't have list v3 or the Istanbul+ report builder enabled, you will need to write a script. The script would query for all groups, then for each group, get the count of the group members. If the count of the group members is exactly 1, then you would write it to the log or do something else with it.


Groups with 1 member.png


List v3 groups.png


Is there a "new" way to do this? I've looked and the "Related List Conditions" section is nowhere to be found. EIther the implementation (SNOW) has changed or I somehow don't have the privileges to access this. I'm trying to find Problems without associated Tasks (PTASK).  Thanks!!

bbf3562
Kilo Guru

What do you want to use to identify groups that have 1 member? If it a script, then you can use like this as example,



var grp = new GlideRecord('sys_user_group');


grp.query();


while(grp.next()){


    //Query for the number of group members


    var grpm = new GlideAggregate('sys_user_grmember');


    grpm.addQuery('group', grp.sys_id);


    grpm.addAggregate('COUNT');


    grpm.query();


    var groupMembers = 0;


    if(grpm.next()){


          groupMembers = grpm.getAggregate('COUNT');


          grp.u_group_members = groupMembers;


    }



The script above go through all groups and count how many members each group. You can add verify in that script if the group have 1 member then you do something from there.


Deepak Kumar5
Kilo Sage

You can run background script below with condition count =1


Duplicate Record Scripts