Show ONLY GROUPS which have MEMBERS in it.

Aakanksha Kotti
Tera Contributor

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. 

3 REPLIES 3

Zach Koch
Giga Sage
Giga Sage

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(',');
}

 

 

 

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!

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?

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