User field should show users depending on the selection group selected in group field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2024 08:10 AM
Hi
I had requirement to allow the user to select multiple users (list collector type) on user field and users should be populated depending on the group selected on group field referring to sys_user_group table. Can you please help me how to achieve this. I have given a trail calling script include from user field and writing onchange client script but not working . I have given below reference qualifier as well by referring user field to group member table but created field is showing up as it has display value as true . I tried removing this dispaly value and adding other fields to show up using variable attributes but no luck, display value is showing up
javascript:"group="+current.variables.<group_variable_name>;
Can someone help on the script part how to achieve this
Thank you,
Anusha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2024 10:13 AM
You will need to create a script include. Then call that from the variables reference qualifier. The variable should point to the sys_user table as the script include will return the users who are a member of the group. I made mine client callable in case I ever needed to use a client script to call it. Below is the script include code.
var UserGroupSCI = Class.create();
UserGroupSCI.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getMembers: function(groupId){
var id = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery("group", groupId);
gr.query();
while(gr.next()){
id.push(gr.getValue("user"));
}
return "sys_idIN"+id.join();
},
type: 'UserGroupSCI'
});
The reference qualifier should look like this.
javascript: new UserGroupSCI().getMembers(current.variables.<group_variable_name>);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2024 11:59 PM
Hi Brian,
It is not working as expected. Instead group members it is showing all users from user table.
I have given as user field as list collector and written given script include and called this script include from reference qualifier like below
javascript:new PopulateUser().getUsers(u_group_name);
But no luck. I have simply tried using refernce qualifier by keeping user field to group member table but it is giving created date as display value of created date is true. But I don't want to change this as it is global change. Can you please help me with the solution
Thanks
Anusha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2024 05:46 AM - edited 12-15-2024 05:48 AM
Hi @anushadande1793,
I am Using Reference Qualifier it is working for me in Service portal (For native view you need to click on Run-Filter button after choose the Group). I am Choosing "CAB Approval" as a group and it is showing the group member in list collector variable.
May You choose sys_user table You need to take "sys_user_grmember" as list table on list collector variable.(Please see below screen shot).
Note: If you are seeing the created date instead from user name you need to change display=true for user field in sys_user_grmember table as below:
Please accept as solution!
Thank You!
Chandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 01:50 AM
Hi @anushadande1793 ,
Did this way resolved your issue ? Let me know if you need any further assistance!
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful".
Thank You!