- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 06:07 PM
Requirement:
Reference field should populate members of a group.
I have a reference field which is referenced to sys_user table. Right now I have all users being populated, but I want users which are a part of a group only to be included in this.
I know it requires a script include and javacript on the reference qualifier. Could someone help me with the script include and how to call is on the advanced reference qualifier.
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 11:02 PM
You can follow this in case your requirement is to just show list if all users who are part of any of the groups in system. You can enhance he script further for more filters in case you want like filter on only users that are active or groups that are active or both
1. Create a script include with name "getUsersWhoAreMemberOfAnyGroup"
2. Set Client callable flag to true
3. Copy/Paste below code in the script include (remove all code that is there already)
function getUsersWhoAreMemberOfAnyGroup(){
var userArray = [];
var groupMembers = new GlideRecord('sys_user_grmember');
groupMembers.query();
while (groupMembers.next()){
userArray.push(groupMembers.user.sys_id.toString());
}
return userArray;
}
Note: If you change name of script include then change the name of function also to be the same as script include name
4. Now go to dictionary record of your user field where you want to put this filter & click on Advanced View related link
5. In Reference specification section set "Use reference qualifier" field to Advanced
6. In Reference qual field paste below
javascript:"sys_idIN"+getUsersWhoAreMemberOfAnyGroup()
Hope this works for you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 09:17 PM
Hi Thomas,
Do you want to show only the users who are part at least in one group?
Thanks
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 10:00 PM
Yes, I want to show only users who are part of a group. I cannot use group member table as it would not meet the requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 10:04 PM
Okie
You can use reference qualifier and script include.
Have you tried anything or let me know I will help you with the sample code.
Thanks,
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 10:06 PM
@Thomas
Do you want to show only AD group users?
Murthy