The CreatorCon Call for Content is officially open! Get started here.

How to filter the Lookup Select Box values based on the Select Box values?

Sudesh
Tera Contributor

In catalog item, i had two variables with type Lookup Select Box & Select Box

i had variable type Select Box with two choices like automation & nonautomation.

Based on the selection of the choice , the Lookup Select Box values should filter the values in the table (location table)

There are no Reference values between the two variables

6 REPLIES 6

Hi @Sudesh , Try using advanced reference qualifier for the same.
Create a script include, Add the code below:

 

var getLocation= Class.create();

getLocation.prototype = {
 initialize: function() {},

getFilteredLocation: function(a) {

 var LocList = [];
var x = a;
var c = 'GA';
if(x == 'automation')
{c = 'TX';}

 var grLocation = new GlideRecord('cmn_location');


grLocation.addQuery('state', c);
 grLocation.query();

while(grLocation.next()) {
 LocList.push(grUser.getUniqueValue());
 }

return 'sys_idIN' + LocList;

 },
 type: 'getLocation'
};

Please adjust the variables as per your enviroment.
Navigate to reference qualifier in the field and write the below line in advance ref. qualfier

javascript&colon; getLocation().getFilteredLocation(current.variables.<selectBoxFieldName>);

 

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

In addition you must specify attribute ref_qual_elements for the Lookup Select Box to which the reference qualifier is applied.

Note that there is a small mistake in the above solution; the usage should include the new keyword:

 

javascript꞉ new getLocation()...

 

*) note that the colon is not a real colon in my example, so make sure to use a proper colon should you copy anything from here.