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

Lookup Select Box - how to change depending on another lookup select box

L_10
Kilo Contributor

Hi community,

I have trouble changing options of a lookup select box, and I couldn't find past articles which can help my situation.

 

Lookup Selection Box A: where users choose item name to order (there are a lot of items to be ordered packed in a service catalog... this may be a cause of this trouble...)

Lookup Selection Box B: where users choose item size, and displayed size option should depend on the option selected in A.

 

Both options are referenced from the same master table.

However, the query filter seems somehow only work within the table.

Such as, when I set to 

type | is | for men

it worked.

However, when I set to 

item name | is same as | <value of A>

it didn't.

btw, I first switched to the type to "Reference" instead of "Lookup~" and I set the Reference qualifier condition.

The condition seemed ok, but when I switched to "Lookup~", the reference qualifier said,

item name | is same as | item name (the same field of the same table)

 

Is there any way to rewrite this reference qualifier or create Client Script to work it just as I want? 

I also failed to work with a client script... (see the image & script below, please)

find_real_file.png

 

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

//Type appropriate comment here, and begin script below
g_form.clearOptions('u_item_size_women');

var choice = new GlideRecord('u_uniform_item_master');
choice.addQuery('u_item_name', newValue);
choice.query();
while(choice.next()){
g_form.addOption('u_item_name',choice.u_item_size);
}
}

Thank you!

7 REPLIES 7

rad2
Mega Sage

can you share the variable reference qualifier?

Something like this should work

reference qualifier

javascript: 'u_item_size_women='+current.variables.item_name_women;

Also, check if the ref_qual_elements is set that is available in Default Value --> 

ref_qual_elements=item_name_women
 
here, i assumed <field A > - item_name_women
<field B> - u_item_size_women
 
Hope this helps!!

L_10
Kilo Contributor

Thank you Rad,

 

<field A> u_item_name_women

<field B> u_item_size_women

Both are in a Variable set "u_vset_women".

 

The column to query with field A is "u_item_name".

The column to get values is "u_item_size".

 

So I adjusted field names as below:

javascript: 'u_item_name.value='+current.variables.u_vset_women.u_item_name_women;

 

At least, the field B started to display all select options, however, including NOT the ones concerning field A's value.

I suspect ".value" part after "u_item_name" is incorrect...

 

Would you please help me a little more?

the below should work

javascript: 'u_item_name='+current.variables.u_item_name_women;

 

in the variable attributes, do add the ref_qual_elements 

Do let us know if this works

L_10
Kilo Contributor

Thank you, rad,

 

however, no fruit yet...

find_real_file.png

earlier, the size field showed simply all the size options,

now somehow nothing except "--None--" is displayed.

 

Just to make sure, am I writing the correct variable attribute?:

     ref_qual_elements=u_item_name_women

 

I am very grateful if you could help me a little more.

 

Cheers,

Lit