Show group member in list collector based on another variable from sys_group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi,
How can we filter the list of user in list collector based on what is selected to another variable,
variable 1 = group
variable 2 = goal is to show list of member only based on selected in variable 1.
In my mind I need to use onchange and script include.
I saw this post that are sample to populate in reference qualifier : Solved: How to show only users from respective group in re... - ServiceNow Community
I applying this concept but I try to add onchange to pass the value of sysid of the group into script include so in reference qualifier will display members.
script include:
but not its not working.
Anythoughts how to show member of the group in catalog using onchange/script include/reference qualifier ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago - last edited an hour ago
Inside the while loop use gr.getDisplayValue('user')
Refer below for sample script
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
not work,
maybe the problem is using my onchange script not in script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
50m ago
Hi @Jeck Manalo,
How are you setting the value in the client script, could you please share image of that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
39m ago
Hi @Jeck Manalo ,
You’re passing sys_id of the group, but in your query you’re filtering on group.name. That won’t match!
script include
getMembers: function () {
var groupId = this.getParameter('sysparm_group_id');
var arr = [];
if (!groupId)
return arr.toString();
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", groupId); // usee sys id not name
gr.query();
while (gr.next()) {
arr.push(gr.user.toString()); // return user sys_ids
}
return arr.toString();
}
and if you are settign the value using the client script try this
ga.getXMLAnswer(function(response) {
var users = response.split(',');
g_form.setValue('user_variable_name', users.join(',')); // populate list collector
});
if youa are setting the referance qualifer then try this scriptjavascript: 'user IN (SELECT user FROM sys_user_grmember WHERE group=' + current.variables.group + ')'