- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 02:29 PM
I have a Reference field in a Record Producer. The Reference field points to the User table.
I want the field to only display members of a specific group.
How can I build the reference qualifier to restrict the choices to the users who are members of the group?
Can I use an encoded query string or will this require a script as described in the wiki article?
Reference Qualifiers - ServiceNow Wiki
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 02:35 PM
You will have to have something query the sys_user_grmember for the users in that group, then feed it into your reference qualifier in a sys_idIN type statement, like:
Re: Reference Variable Filtered by Group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 02:35 PM
You will have to have something query the sys_user_grmember for the users in that group, then feed it into your reference qualifier in a sys_idIN type statement, like:
Re: Reference Variable Filtered by Group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2015 12:10 AM
First you need to create a client callable script include query from sys_user_grmember, would be something like that
var filterUser = Class.create();
filterUser.prototype = Object.extendsObject(AbstractAjaxProcessor, {
filter: function(groupID){
var Buildusers = ' ';
var usr = new GlideRecord('sys_user_grmember');
usr.addQuery('group',groupID);
usr.query();
while(usr.next()) {
if (Buildusers.length > 0) {
//build a comma separated string of users if there is more than one
Buildusers += (',' + usr.user);
}
var result = 'sys_idIN' + Buildusers;
return result;
},
type: 'filterUser'
});
after writing your Script include you need to call your script from the reference qual
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2016 05:10 AM
You could also use encoded script, something like:
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2021 08:48 AM
nice touch. You can do this without cerating a custom script include.