Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Server-Side Components/MemberLessGroups/MemberlessGroups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var arr=[]; //empty array that can be used later to capture the group names
var gr = new GlideRecord("sys_user_group");
gr.addActiveQuery();//active query to capture to query through all the active groups
gr.query();
while(gr.next()){
var br= new GlideRecord("sys_user_grmember"); //querying grmember table to validate group's members
br.addQuery("group",gr.sys_id.toString());
br.query();
if(!br.hasNext()){ // if no member then capture the group name in the array
arr.push(gr.name.toString());
}
}
gs.print(arr.join(",")); //printing the array with all the memberless group names
13 changes: 13 additions & 0 deletions Server-Side Components/MemberLessGroups/ReadME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This background script captures all the groups which are active and do not have any members added to the group.

What your script does correctly

Queries all active groups from sys_user_group.

For each group, it checks sys_user_grmember to see if there’s at least one member.

If no member exists (!br.next()), it pushes the group name into arr.

Finally, prints all such group names, comma-separated.

So logically, it works fine and will print all active groups with zero members.
Loading