.addOption for catalog variable (lookup select box) in case ref qual not satisfied - BUT only on first change!!!

Zod
Giga Guru

Hey,

SO strange. I need help here!

I have a scoped variable set up as a lookup select box and link to a custom table that contains similar entries like sys_choice ... to be used for the lookup.

I'm using a ref qual condition that works fine when choosing valid entries from the table within a catalog item ... All fine!

No I need for certain cases (depending on a change mad in an other variable) to ADD an OPTION that is NOT part of the table I'm using for my choices.

SO a have a catalog client script on change, that sets the ADDITIONAL option (not matching the ref qualifier) in case required (and I also found an way to remove it again in case the other value changes again ... ).

All works fine ... just the first time the option is to be set, it disappears again! Looks link there would be some other setting redoing what was just done in the catalg client script. I added an alert at the end of the client script and when it pops up the correct value is still there. Just overwritten with blank afterwards.

I 5 times checked ALL client scripts ... none of them can be responsible for overwriting.

And anyhow .. when changing the variable causing it .. back and force it works .. allways ... its JUST the first time this does not work ... anyone with an idea? Look more like a bug to me ... 

1 ACCEPTED SOLUTION

Table?! We are still talking about variables .. 

BUT I found it myself. Its the reference qualifier I'm using to define what kind of values are valid on the lookup select box. This technically is most probably nothing else than a client script. As the values initially are set via the change on an other variable - this will be "loaded" afterwards. So I need to remove the ref qualifyer there and buid in the logic manually within a client script.

Anyhow ! Thnx for your effort!

View solution in original post

29 REPLIES 29

Please see other reply.

Refreshing the page will reset all options and all will start over again ...  . As I said we are talking about a catalog client script and a catalog item (with variables ... not fields).

Have you tried out the solution produced by Paul?

Do not think this is possible in my case.

The standard choice list is updated daily and the additional values will only be known if reference is selected. To the option can only be added when reference is selected - and need to be removed again if other reference is selected ... 

Ok, Have you checked any UI policies that might be making the option disappear? and any other onchange scripts? I have tried this on my dev instance and it seems to work fine.

What i have done is

- created a catalog variable of type lookup select box. Ex

find_real_file.png

 

- added an onchange client script 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
    g_form.addOption('addoption_catalog', 'Additional', 'Additional');
}

 

Now when i change the reference field, the choice option gets added the first time and i can select it.

Hope this helps

Difference to my scenario is, that I get the new option via ajax call ... to this will run async ... .

The other difference is, that I'm not using the sys_choice table for the options, but a customer table as we have need for additional parameters ..