How to filter a Lookup Select Box based on another variable in a variable set?

barbaratosetto
Tera Contributor

Hi everyone,

I'm working on a Catalog Item that uses a Variable Set with two variables:

  • application_type → Select Box (with static options)

  • application_name → Lookup Select Box (pulls from a custom table u_business_application_map)

The goal is for application_name to display only records where u_application_type matches the selected application_type.

Here’s what I’ve tried so far:

Setup:

  • Both variables are part of the same Variable Set (Application Info)

  • application_name is a Lookup Select Box pointing to u_business_application_map

  • Lookup value field: Application Name

  • application_type contains static values that match what's stored in u_application_type (already verified)

The first attempt was to create a Catalog Client Script onChange:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') return;

var filter = 'u_application_type=' + newValue;
g_form.setReferenceQual('application_name', filter);
g_form.refreshReferenceField('application_name');
}

 

However, it didn't work. The application_name field still displays all records, not filtering it.

 

The second attempt was using Reference Qualifier:

 

var query = '';
if (current.variables.application_type) {
query = 'u_application_type=' + current.variables.application_type;
}
query;

 

But that also had no effect — all values still show up regardless of the selected type.

 

Is there anything that I'm missing? Or another approach that I should try?

 

barbaratosetto_0-1749695590370.pngbarbaratosetto_1-1749695626112.png

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@barbaratosetto 

you should set advanced ref qualifier and not client script

something like this, ensure you give correct field name and I assume drop down for application type with choice value matches with the field on that table

javascript:'u_application_type=' + current.variables.application_type;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@barbaratosetto 

you should set advanced ref qualifier and not client script

something like this, ensure you give correct field name and I assume drop down for application type with choice value matches with the field on that table

javascript:'u_application_type=' + current.variables.application_type;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader