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

in the script include function make this the first line


gs.addInfoMessage('hello Laurie');



This will tell you whether the issue is in the script include function or while calling, If this message appears on the lookup window then this function is wrong, otherwise we are calling it in a wrong way.



Do this and then we will solve it


-Anurag

The message did not appear, so the issue must be when calling.


Try this in the reference Qual



javascript:new GetGroupMember().getMember();


-Anurag

I got the "hello Laurie message!   But no user names...


that is because you are returning the string "sys_idIN*****" and instead of sys_id you added the names of users



so in the script include function replace "user_array.push(getMembers.user.getDisplayValue());"


with


"user_array.push(getMembers.user);"


-Anurag