Filter Lookup selectbox variable choices based on variables in variable set.

Deepak Shaerma
Kilo Sage

Hi Community, 

I want to put reference qualifier filter on lookup selectbox variable based on the variable in variable set.
I have 15 checkbox variables and based on these i need to filter the lookup selectbox, need the reference qualifier condition or any another best approach.

Thanks & Regards

Screenshot 2025-07-15 at 12.15.17 PM.png

 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Deepak Shaerma 

you can always access the checkbox variable in advanced ref qualifier of Lookup select box variable and then form the query

Syntax -> current.variables.checkboxVariableName1

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

@Deepak Shaerma 

Thank you for marking my response as helpful.

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

Shraddha Kadam
Mega Sage

Hello @Deepak Shaerma ,

 

Write onChange client script to achieve the functionality.

If my response was helpful, please mark it as correct and helpful.
Thank you.

iekosmadakis
Mega Sage

Hello @Deepak Shaerma !
current.variables.<varName> is available in an advanced qualifier and returns the live value of each variable. Below is an example of an advanced reference qualifier that you can adjust to your needs in an editor and paste in the reference qualifier field of the lookup select box:

javascript :

(function () {
    // list the check-box variable names once
    var boxes = [
        'system_a','system_b','system_c',/* … */'system_o'
    ];

    var selected = [];
    boxes.forEach(function (v) {
        if (current.variables[v] == 'true') // checkbox checked
            selected.push(v);
    });

    // Build the filter (u_subsystem is just an example field)
    var q = 'active=true';
    if (selected.length) {
        q += '^u_subsystemIN' + selected.join(',');
    }

    return q; // MUST return a string
})();

 

Please consider marking my answer as helpful and accepting it as the solution if it assisted you in any way.