- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2015 08:32 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2015 11:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2020 11:06 AM
Hi All,
The above mentioned answers are definitely correct and very helpful. But I think we have a very simple way to do that.
Please follow this HI Article link: https://hi.service-now.com/kb_view.do?sysparm_article=KB0831564
Instructions
It is filtering the sys_user reference list depending on the current value of the group field of the current record using an advance reference qualifier with the expression:
This approach could be applied to meet the customers requirement to display only active users that belong to a specific group with sys_id=Your group sys id
I suggest in your reference field you use an advanced reference qualifier with the following expression:
javascript:'active=true^sys_idIN'+getIDs("Your group sys id"); function getIDs(grp){var m=GlideUserGroup.getMembers(grp);var ids=''; while (m.next()){ids+= (m.user+',');} return ids;}
Please Mark Correct if it was helpful for you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2020 11:48 PM
Thank you very much, Chris! Just what I was looking for!
Best regards
Thomas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2020 09:27 AM
Thanks a Bunch!
That is a life saver...
As mentioned above by Chris, follow this HI Article link for detailed information...
This does exactly what I wanted, after troubleshooting for over an hour looking at other references, videos, documentation...
After watching this video from Chuck Tomasi, I realized I used the wrong reference table!
I had mistakenly referenced it to the Group Members [sys_user_grmember] instead of using the User [sys_user] table.
So, plain and simple:
- Create a Reference Field referring to the following Table: User [sys_user]
- Configure the Dictionary for the newly created reference field (use Advanced View)
- Navigate to the "Reference Specification" tab
- Fill out the following fields:
- Reference: User
- Use reference qualifier: Advanced
- Reference qual: javascript:'active=true^sys_idIN'+getIDs("replace with your group sys_id"); function getIDs(grp){var m=GlideUserGroup.getMembers(grp);var ids=''; while (m.next()){ids+= (m.user+',');} return ids;}
Refresh your form and your new Reference Field should now display only the members of the group you have specified in the "Reference qual" above.
I know this might seem simple enough and I am repeating what most people said but I hope this will help someone out there not lose hours of their lives they won't be able to get back 😉
I hope this will help someone else out there!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 02:24 PM
Is it possible to adapt this ref qualifier to filter against two groups instead of just one? i.e. supply 2x sys id's?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 05:39 PM
Been a while, but iirc isn't the GetGroupedUsers() second parameter a list? You can try supplying comma separated format e.g. "group1,group2".