How to check if variable exists in java script

if the variable exists already you have 2 options

  1. delete the variable from the manager and re-create:
    camForm.variableManager.destroyVariable('inputOrderName'); camForm.variableManager.createVariable({name:'inputOrderName',type:'String',value:'myNewValue'});
  2. overwrite the variable value
    camForm.variableManager.variableValue('inputOrderName', 'myNewValue');

If you look at the source code of the variableManager you see that an entry is made when you invoke fetchVariable but only the name will be filled, not the value. I’m not a fan of this behaviour but it’s just the way it works.

2 Likes