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

Help to setup active=true filter on reference qualifier

laszlobolya
Kilo Expert

Hi guys I`m struggling with a reference qualifier.

I have a record producer.

1. variable, lookup box - list trade_name from Main table. variable name is 'subcategory'.

2. variable, List collector, list other_name from Sub table. this table also contains same trade_name field, same as for Main table.

Goal is to only display other_names on Sub table List collector where the trade_name is that selected on lookup box named subcategory

I can reach that!

Reference Qualifier on List collector: javascript:'trade_name='+current.variables.subcategory;

Variable Attributes: ref_qual_elements=subcategory,no_filter

Perfect, when I change the subcategory correct other names listed on the List. BUT. I want to List on the collector only the Active other_names. Can`t setup the correct reference qualifier.

So I tried:

active=true^javascript:'trade_name='+current.variables.subcategory;     -- this load all Active other names, but ignores what I select on subcategory.

javascript:'trade_name='+current.variables.subcategory^active=true;     -- list all the items including inactive, ignores what I select on subcategory

Tried some another combinations also No succes. Do you have any suggestion please? Thank you!

1 ACCEPTED SOLUTION

Hi Laszlo,



Sorry, it looks like the script that I referred you to is out of date; my apologies.   The script on the original article on ServiceNow Guru is updated and contains a bit more, which I have included below as well.   One thing to note as well is that this will need to be an onChange client script rather than an onLoad.



function onChange(control, oldValue, newValue, isLoading) {


    //Apply a filter to the list collector variable


    var collectorName = 'other_name';


    var filterString = 'trade_name=' + current.variables.subcategory + '^active=true';


 


    //Reset the filter query


    window[collectorName + 'g_filter'].reset();  


    window[collectorName + 'g_filter'].setQuery(filterString);  


    window[collectorName + 'acRequest'](null);  


}


View solution in original post

6 REPLIES 6

Robert, many thanks!


It is working, with two comments:



instead of current. I need two use g_form.getValue (script error saying that current cannot be used in client scripts)


Also, I need to move this client script into a global app instead of my scoped app, but I can accept this right now. (within app scope it says other_nameg_filter cannot be null. So this is what I have now and it seems this is what I need though I do some testing still. Many thanks for your help!



function onChange(control, oldValue, newValue, isLoading) {  


    //Apply a filter to the list collector variable  


    var collectorName = 'other_name';  


    var filterString = 'trade_name=' + g_form.getValue('subcategory') + '^active=true';  


     


    //Reset the filter query  


    window[collectorName + 'g_filter'].reset();      


    window[collectorName + 'g_filter'].setQuery(filterString);      


    window[collectorName + 'acRequest'](null);      


}  


Hi Laszlo,



Of course you are correct about current not being available client side; my mistake.   Glad you were able to get this working!