reference qualifier script member of group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2016 03:06 PM
This has come up for me enough times and I don't want to continue to rely on our outside implementers.
I need to create a reference qualifier that is scoped to a particular group. Can someone let me know what that script would look like? I thought I was close a couple times, but I keep missing it. sys_user field that references only a particular group.
This would be a big help.
Thanks,
Karen

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2016 01:59 PM
No problem.
If you select "Advanced" for your type of Reference Qualifier on 'u_student_assigned_to', you can copy/paste the following to give you only users in a specific group. Just insert your specific group's sys_id where I've noted.
1. Enter the following as the reference qualifier:
javascript:var gr = new GlideRecord('sys_user_grmember');gr.addQuery('group',"<insert your group's sys_id>");gr.query();var users='';while(gr.next()){users+=gr.user.sys_id + ",";}"sys_idIN" + users;
2. You could also store the meat of that in a script include as a function, and then call it from your refqual...
Script Include: getGroupMembersList
function getGroupMembersList(groupId){
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', groupId);
gr.query();
var users='';
while(gr.next()){
users+=gr.user.sys_id + ",";
}
return users;
}
Then in your refqual, you would call it as:
javascript: "sys_idIN" + getGroupMembersList("<insert your group's sys_id>")
Either one of these methods should work for you.
Thanks,
-Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 02:40 PM
This is exactly the answer, cheers Brian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 03:31 PM
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 05:54 AM
I'm trying to do something similar, needing a list of all members of a certain group.
But when I Reference to the sys_user_grmember table, I can't seem to select a value from my list, nor does it autocomplete on typing....
What am I doing wrong? 😕

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 11:23 AM
Hi Chris,
it would be best to lay out the details of your use-case/scenario, and provide the details/screenshots of what you are already trying.
e.g., Are you trying to pick a user? Then your reference needs to be to [sys_user] instead, and you would use some script/qualifier to narrow the list based on what's in [sys_user_grmember].
if(more_detail == better_info){
var result = what_you_are_looking_for;
}
return result:
Thanks,
-Brian