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 Chrystie
ServiceNow Employee
ServiceNow Employee

Hi Laszlo,



I would recommend reviewing Christopher Plunkett's response on Re: Catalog List Collector variable: Set filter?The reference qualifier that you have should help when the form loads, but an OnChange Client Script is needed to adjust the filter in real time as other values change.


Yeah, I have read that. I was so hopeful I can avoid such a client script I will see.


Anyway thank you for your reply. Basically the problem I discover now, and had it earlier also:


This onload catalog client script set the other_name field on List collector only for Active values:



function onLoad() {


  setTimeout(setMyFilter, 1000);


  //wait to make sure filter is loaded, i think the article you found has a nicer way of doing this


}


  function setMyFilter() {


          other_nameg_filter.reset();


      var answer = '';


      answer += 'active=true'; //


      other_nameg_filter.setQuery(answer);


      other_nameacRequest(null);


}



but when I add the reference qualifier field on other_name:


javascript:'trade_name='+current.variables.subcategory;



then it displays None



so somehow I cannot "merge" the result, get active items but only for subcategory selected. The reference qualifier field and the setfiler onload script somehow just kills each other.


They are good stand alone, but together not


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);  


}