Reference Variable Filtered by Group

Laurie Marlowe1
Kilo Sage

Hi,

I have a reference variable called "Project Lead".   I want to only show members of the Physical Security group in this field.   From what I've read it seems a reference qualifier should be used.   After reading some articles I tried entering the following:

Reference qualifier:   javascript:new GetGroupMember().getMember(bb3fc3056f68e10006a8f00dba3ee483)

I'm passing the sys_id of the Physical Security group.

Script Include:

var GetGroupMember= Class.create();

GetGroupMember.prototype = {

getMember : function(bb3fc3056f68e10006a8f00dba3ee483)

{

   

      var user_array = [];

      var getMembers = new GlideRecord('sys_user_grmember');

      getMembers.addQuery('group',bb3fc3056f68e10006a8f00dba3ee483);

      getMembers.query();

      while(getMembers.next())

              {

                user_array.push(getMembers.getValue('users'));

      }

      return 'sys_idIN' + user_array.toString();

}

};

What happens is I get the entire sys_user table unfiltered.   How do I just get the members of the Physical Security group so I can select one of them?

Any help is appreciated, as I am new to scripting.

Thanks,

Laurie

1 ACCEPTED SOLUTION

Please see my other reply as it will correct this situation.


View solution in original post

36 REPLIES 36

Nadia10
Tera Contributor

Thanks for the response. I thought the same, but when I try:-

javascript:'active=true^sys_idIN'+getIDs("sysid1,sysid2");

The ref qual doesn't return any results at all when I try it against the variable.

Also tried it with each sysid enclosed in quotes, but that didn't work either.

 

with just the below it works fine, but obviously only for one group. Anybody have any ideas on what I might be missing? or an alternative method for qualifying against 2 groups instead of just one? Thanks in advance.

javascript:'active=true^sys_idIN'+getIDs("sysid1");

Nadia10
Tera Contributor

Got it to work with two groups by restructuring as per the snippet below to use addOrCondition

gr.addQuery('group',"sysid123").addOrCondition('group',"sysid123");