- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 07:54 AM
I have a custom reference field where i want to return all the group members from one group (to be able to select one). At the moment it points to sys_user_grmember and it just returns the group name multiple times. I'd rather not customize anything about sys_user_grmember as that is used in other modules. Found the encoded query below to add into the attributes of the reference field, but it doesnt seem to have an affect.
Also tried to modify the columns attribute using ref_ac_columns=user, but that do anything either.
Encoded query tried:
javascript:var gr = new GlideRecord('sys_user_grmember');gr.addQuery('group',"<group sys id here>");gr.query();var users='';while(gr.next()){users+=gr.user.sys_id + ",";}"sys_idIN" + users;
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 08:08 PM
I used a clean PDI to add a field called App Devs on the incident table to only return the users in the Application Development group.
Final outcome after clicking lookup:
Column entry:
Script Includes:
Group:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 08:08 PM
I used a clean PDI to add a field called App Devs on the incident table to only return the users in the Application Development group.
Final outcome after clicking lookup:
Column entry:
Script Includes:
Group:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 07:17 AM
This works. Very helpful Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2024 06:43 AM - edited ‎05-06-2024 06:50 AM
I have gone through all the replies, I found better resolution among all listed.
Please go through below knowledge article
How to select only users of a specific group into a reference field
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0831564
Note: Some times it will throw error "GlideUserGroup is not allowed in scoped applications"
in that case you can use below advance ref qualifier: (replace sysid with your Group's sysid.
javascript:'active=true^sys_idIN' + getIDs('f21254021bc1b110870286e1604fcf0e'); function getIDs(groupSysID) { var members = []; var gr = new GlideRecord('sys_user_grmember'); gr.addQuery('group', groupSysID); gr.query(); while (gr.next()) { members.push(gr.user.toString()); } return members.join(','); }