Show ONLY GROUPS which have MEMBERS in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 06:00 AM
I have a requirement where there is a field called Approval Group, which is of 'LIST' type, which is referencing to the Group table.
I wanted to show only list of groups which have members in it.
Kindly let me know how this can be achieved by advanced reference qualifier.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 06:22 AM - edited 07-15-2024 06:23 AM
You are likely going to need to do an Advanced Reference Qualifier calling a Script Include and use a function like this
getGroups: function() {
var groupsWithMembers = [];
var groupGr = new GlideRecord('sys_user_grmember');
groupGr.query();
while (groupGr.next()) {
if (groupsWithMembers.indexOf(groupGr.group.sys_id.toString()) == -1) {
groupsWithMembers.push(groupGr.group.sys_id.toString());
}
}
return 'sys_idIN' + groupsWithMembers.join(',');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 07:04 AM
Hi,
Thanks for your response. It worked!
but we have an additional requirement we want to include groups with type either 'approval' OR 'itil'.
We tried by using this reference qualifier condition -
javascript:new AdhocGroups().getGroups()&&(typeLIKE1cb8ab9bff500200158bffffffffff62^ORtypeLIKEa10e937a1bc50010031da8a07e4bcb30^EQ)
But it didn't work. Do you have idea on how we can achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 07:28 AM
Hello @Aakanksha Kotti ,
Please include the encoded query for the group type in addition to the code provided by @Zach Koch .
getGroups: function() {
var groupsWithMembers = [];
var groupGr = new GlideRecord('sys_user_grmember');
groupGr.addEncodedQuery('group.type=1cb8ab9bff500200158bffffffffff62^ORgroup.type=a10e937a1bc50010031da8a07e4bcb30');
groupGr.query();
while (groupGr.next()) {
if (groupsWithMembers.indexOf(groupGr.group.sys_id.toString()) == -1) {
groupsWithMembers.push(groupGr.group.sys_id.toString());
}
}
return 'sys_idIN' + groupsWithMembers.join(',');
}
Please mark my answer as correct and helpful if it resolves your query.
Thanks,
Alka