Thnx. Helpful - but for other purposes.

Just explain the thing .. .

 

We have CI, that can be modified via a service request. Therefore the values of the CI fields are added to the catalog item into a variable to be able processing it. But the same catalog item can be used to initially add a CI. In both scenarios, a field X need to be filled. In case a new CI, the allowed choices are available in a custom table and I use a lookup selectbox (as I need the variable attributes to get the correct choices only depending on some condition). But when changing the CI, the value can be changed to the allowed choices OR the already set value can be kept (so this is why I need to add this option when the relevant record is selected). 

But as the catalog item need to be flexible, we also can change the references record, so the options need to "reload" to only the allowed options.

This is why i added a hidden variable to keep the temporary new option and remove if as soon the new record is selected.

As I said - all works as it should when changing the reference ... only the first time I run the on change script the option is set only very shortly and then disappears again. Something tiggers an initial load of that select box after the catalog client script did ran. Just I can not understand what and why. I tried  to set the order of the client script very high ... but no difference.

When I set an alert at the END of the client script to stop the process, the option this there!!!! Just after it ran - is gone again ... . I change to an other reference .. and all is good. Change back to the 1st one .. again all is ok. So its just the first time the script runs it will be "overwritten by something else afterwards ....