How to filter the Lookup Select Box values based on the Select Box values?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2023 01:32 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2023 06:12 AM
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: getLocation().getFilteredLocation(current.variables.<selectBoxFieldName>);
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2023 03:44 PM - edited ‎07-15-2023 03:45 PM
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.