Dependent fields (Glide List Field)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 01:25 PM
In a Demand record I have a field for subgrouping selection (u_customer_segment) which its values are dependent on a grouping field (u_grouping); It works as expected, the grouping limits what you can select in the subgrouping based on an assigned dependent value. I have been asked if I could make both the Grouping and the Subgrouping fields multi-select. I converted the field type to glide_list (Lists/slush buckets) thinking the dependencies would be maintained which is not correct. If possible, can this be simply rectified with a reference qualifier I have tried a number of variations without success. Or will this require a bit more code with a Script Include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 02:39 PM
This may need an Advanced Reference Qualifier that calls a Script Include, depending on the relationship between the two fields. For a more out of the box example, say I have two list collectors on the sys_user table named u_user1 and u_user2. If I put this as the advanced reference qualifier on user2 I will only be able to choose from the users selected in user1:
javascript: 'sys_idIN' + current.u_user1
Note that because this is a list field, I can't dot-walk it, like for example if I wanted to only show users in user2 who were the managers of users selected in user1, I can't change this to:
javascript: 'sys_idIN' + current.u_user1.manager
rather I would have to change it to call a function in a Script Include like this:
javascript: new userUtils().getMgrs(current.u_user1);
Then my Client callable Script Include named userUtils that has a function named getMgr would look like this:
var userUtils = Class.create();
userUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getMgrs: function(usrs){
var mgrArr = [];
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id', 'IN', usrs);
usr.query();
while (usr.next()) {
mgrArr.push(usr.manager.toString());
}
return 'sys_idIN' + mgrArr.join(',');
},
type: 'userUtils'
});
Hopefully this will get you close for your scenario.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 03:40 PM
my values reside in the choice table (sys_choice) so in the case of a u_user1 and u_user2 the association would be made by the 'dependent value' in u_user2 having a value that is identical with a value in u_user1.
u_user1='u_user2^dependent_value'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2023 04:14 AM
Hi @bnellis - were you able to figure out a way to this? Even I have a similar requirement where
I have two list fields 1. Region 2. Zones. I am using lists field to be able to select multiple values from both the fields. where choices have been configured with dependency in sys_choice table.
User should be able to see the values in Zones field based on Region field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2023 04:47 AM
Hi Nanda,
You have to specify advanced reference qualifier for field Zones and in the reference qualifier pass value of field region.
Please check below code-
Reference qualifier for zone field-
javascript:new userUtils().getZones(current.region);
Script include function -
getZones: function(region){
var ZArr = [];
var grZons = new GlideRecord('sys_choice');
grZons.addQuery('dependent_value', 'IN',region);
grZons.query();
while (grZons.next()) {
ZArr.push(grZons.value.toString());
}
return 'sys_idIN' +ZArr.join(',');
},
Thanks,
Manjusha