Global var not defined in forms js

In the solutions global variables I set a var

var importTarget = null;

Now I’m in the code for one of the forms and I’m trying to test to see if that var has a value in order to enable a button. I’m getting an error

ReferenceError: “importTarget” is not defined.

Shouldn’t the form be able to know that the solution has this global variable?

What am I missing?

Thanks
\

In Servoy, global variables are referenced as follows:

globals.globalVariableName

In your case:

globals.importTarget

Hi,

Are you refering to the variable using the ‘globals’ namespace ?
Any global method and variable live under globals.* so you should refer to it as globals.importTarget.

Also be aware that if you work with modules then the scope of these global methods/variables ‘bubble up’.
So lets say you have the following module reference structure:

[main]----[mod1]----[mod2]
       |
       |--[mod3]

Then when create a global method/variable in mod2 then mod1 and main will ‘see’ that global method/variable. Mod3 will not.
Now if you put it in mod1 then only main will see it. mod2 will not see the global scope of it’s parent module.
And when you put your globals in main then no other module will ‘see’ it.

So when it comes to globals and modules make sure you put them in the ‘lowest’ module that uses these globals.

Hope this helps.