Dependent fields (Glide List Field)

bnellis
Tera Contributor

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? 

6 REPLIES 6

Brad Bowman
Kilo Patron
Kilo Patron

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.

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'

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. 

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