Is there a way to make "include none" lookup select box option dependent on another variable?

Community Alums
Not applicable

Hi all,

So I have a catalog item with a lookup select box variable that has the "include none" option turned on.  This field is dependent on a previous variable for population and mandatory.  My problem is as long as "none" is an option it reads as mandatory but it thinks none is a selection so it marks it with a black asterisk.  This is normally fine, but for one specific choice in the first variable I need it to either not have "none" as an option or I need my users to pick something else.

Is there a way to force this?  Again I can't just uncheck the "include none" option since that needs to be there for every other scenario.  I just need users to select something other than none if the first variable is a specific choice.

1 ACCEPTED SOLUTION

Alexandre Magea
Kilo Expert

Hi Brad,

What you could do is to remove the option "include none", and create an entry that mimics it (Include none - No value).

When your first field changes, use an onLoad script to change the dropdown options.

For instance:

function onLoad(){

g_form.clearOptions('myDropdown');

if (g_form.getValue('field1') == "value1"){

             g_form.addOption('myDropdown', 'option1', 'Option 1');

             g_form.addOption('myDropdown', 'option2', 'Option 2');

}

else

{

             g_form.addOption('myDropdown', '', 'None');

             g_form.addOption('myDropdown', 'option1', 'Option 1');

             g_form.addOption('myDropdown', 'option2', 'Option 2');

}

}

 

However, you mentioned that it's a lookup field?

Maybe you will then need to make an AJAX call to obtain the list of values and label  from the server instead of hardcoding them like I just did.

I hope it helps!

Alex

View solution in original post

1 REPLY 1

Alexandre Magea
Kilo Expert

Hi Brad,

What you could do is to remove the option "include none", and create an entry that mimics it (Include none - No value).

When your first field changes, use an onLoad script to change the dropdown options.

For instance:

function onLoad(){

g_form.clearOptions('myDropdown');

if (g_form.getValue('field1') == "value1"){

             g_form.addOption('myDropdown', 'option1', 'Option 1');

             g_form.addOption('myDropdown', 'option2', 'Option 2');

}

else

{

             g_form.addOption('myDropdown', '', 'None');

             g_form.addOption('myDropdown', 'option1', 'Option 1');

             g_form.addOption('myDropdown', 'option2', 'Option 2');

}

}

 

However, you mentioned that it's a lookup field?

Maybe you will then need to make an AJAX call to obtain the list of values and label  from the server instead of hardcoding them like I just did.

I hope it helps!

Alex