dependent list collectors in catalog form

suvarnamdsk
Tera Contributor

Hey Guys,

I have an requirement to make the list collectors as dependent.
for example, I have three list collector variables with not reference to any table directly(I have custom choices values).
All three visible on the form.  at once.
If I select some options in variable 1 then based on value the choice list in the variable 2 should get filtered.
like wise variable 3 should get filtered from the variable 2 value choices.

I cannot create the custom table.

Searching for a feasible solution!

3 REPLIES 3

Brad Bowman
Kilo Patron

In the second and third variables, have a reference qualifier similar to this:

javascript: 'field_nameIN' + current.variables.var_1 + '^active=true';

Replacing the beginning part with the word javascript and the colon character instead of the garbage that this editor converts that to, then whatever field name(s) and variable name(s) are appropriate in your situation.  

 

On var 2 and 3 you'll also need to add a Variable attribute similar to:

ref_qual_elements=var_1;var_2

So that each list updates when the dependent variable changes.

Hi @Brad Bowman  

Thanks for the reply mate.
but even after giving that ref qualifier we haven't specified the relation between the values in the variable right. so how should i do that also.

the options in the all three variables are different

for example variable 1 is type where i have mobile or laptop as an options

for variable 2 i have the options as android, iphone, asus, dell and mac. and for variable 3 i have recharge, keyboard, mouse, phone case, mobile charger.

if i select mobile in variable 1 then android and iphone should be the available options for the variable 2(list collector).
if i select iphone then mobile charger and some other options should be the list(this is also list collector)
This is the best example i can give now.
where can i mention that. I tried via script include with ajax but no luck in that.

 

 

For this it sounds like you will need the reference qualifier to call a Script Include, passing in the variable 1 (and variable 2) value(s).  The SI will need to return 'sys_idIN' + a joined array of sys_ids from the referenced table.  To build this array of sys_ids, the script will apply whatever logic you have defined, even if it's a manual mapping, for each value passed in from the dependent variable(s).

 

An alternate approach is an onChange script which resets the list filter.

https://www.servicenow.com/community/itsm-articles/advanced-filtering-of-list-collector-variables-de...