Skip to content

Commit ceb19a6

Browse files
authored
Create MemberLessGroups.js
This background script helps developers to check for active groups which do not have members.
1 parent e026d5b commit ceb19a6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var arr=[]; //empty array that can be used later to capture the group names
2+
var gr = new GlideRecord("sys_user_group");
3+
gr.addActiveQuery();//active query to capture to query through all the active groups
4+
gr.query();
5+
while(gr.next()){
6+
var br= new GlideRecord("sys_user_grmember"); //querying grmember table to validate group's members
7+
br.addQuery("group",gr.sys_id.toString());
8+
br.query();
9+
if(!br.hasNext()){ // if no member then capture the group name in the array
10+
arr.push(gr.name.toString());
11+
}
12+
}
13+
gs.print(arr.join(",")); //printing the array with all the memberless group names

0 commit comments

Comments
 (0)