Filter Glide list field values based on other Glide List values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 11:54 PM - edited 11-11-2022 12:11 AM
Hi all,
I have a requirement where I have 2 Glide list in the form. Lets say for an example:
- Group - Type - Glide list (Reference to Group)
- Users - Type - Glide list (Reference to User)
Under each group, we have multiple users.
Group-A | Group-B | Group-C |
User-1 | User-4 | User-7 |
User-2 | User-5 | User-8 |
User-3 | User-6 | User-9 |
I used an advanced reference qualifier in the user dictionary, which is working if I select a single value in a group. But If I select multiple groups, both groups users are not visible in the user Glide list.
If I select 2 groups, both the group users should be visible in the user Glide list.
Can any one help?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 12:23 AM - edited 11-11-2022 12:26 AM
Hi @Venkata Sunil K
You can use below logic for your requirement. Just now tested in my instance and it is working as expected.
javascript: new global.NVS_IT_AdvancereturnRoles().filterusersbyGroup(current.u_assignment); //replace with your function name and field name
//server side script
filterusersbyGroup: function(group) {
var arrM = [];
var grR = new GlideRecord("sys_user_grmember");
grR.addQuery("group", "IN", group.toString());
grR.query();
while (grR.next()) {
arrM.push(grR.getValue("user"));
}
return "sys_idIN" + arrM.toString();
},
(=tested)
Hope it helps:)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 01:19 AM
Hi Murthy, thanks for your assistance!
I tried the logic as you suggested but its not working.
Script Inlude:
myFunction: function(caseType) {
var arrM = [];
var grR = new GlideRecord("sn_hr_core_case_sub_type");
grR.addQuery("u_case_type", "IN", u_case_type.toString());
grR.query();
while (grR.next()) {
arrM.push(grR.getValue("u_name"));
}
return "sys_idIN" + arrM.toString();
},
Advanced Reference Qualifier:
javascript: new myScriptInclude().myFunction(current.case_type);
I'm missing something here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 02:10 AM
Update the line like below and try:
grR.addQuery("u_case_type", "IN", caseType.toString());
If still not works keep some logs in while loop and post the results here.
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 02:15 AM
your script and your example are different
what's your actual requirement here? to show users based on group selected or related to HR?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader