
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 01:57 AM
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 ...
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 06:10 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 06:21 AM
Glad you found it! 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 02:07 AM
And yes - no other ui policies that seem to be relevant
and yes - no other client script referring to this variable ...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 12:21 AM
It sounds like you are trying to use the Variable in such a way that isn't really supported.
I'd suggest tackling this from another angle.
How about adding this value to this list, but hiding it until your specific pre-condition is met?
You could do this with a Reference Qualifier script.
Let's say you need to add an option when the variable "edge_case" is true
RefQual= javascript:YourRefQualLogic()
Script Include (Client Callable)
function YourRefQualLogic() {
if (current.variables.edge_case == 'false') {
return "active=true^value!=edge_case_option";
} else {
return "active=true";
}
}
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 12:41 AM
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 ....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 12:59 AM
It looks like the ajax call getting the values from the CI records is just faster than the "normal" load of the variable and its options ....