Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Strange issues with global variables


Former Community Member

I encountered some problems while trying to work with global variables.

Sometimes it happens that when I want to get the value of a variable, it just returns 'undefined' or 'NaN'...

All I did was declaring a global variable (File -> Form properties and also global.xyz = ...; on the initialize event of Document1, I've used both methods) and adding +1 to it when pressing a button.

This would look like:


global.test = 0; (Document initialization)

app.alert(global.test); (Button click event)



The strange thing is: Sometimes I can count up to values greater than 50 before the program "loses" the variable, sometimes it happens already at 10 or below and in other cases it is undefined already when I open the document.

However, I did not change anything in my script.

Is there another way to declare and use global variables?

May it also be possible that these problems are normal when you use the trial version of LiveCycle Designer ES?
3 Replies


Former Community Member
The variable should be accessed using its value property like this:

VariableName.value = 1

The trial version of Designer has nothing to do with this.


Former Community Member
I figured out that my problem no longer exists when I uncheck the option "Strict Scoping rules for JavaScript" in File -> Form properties -> standards.

Can someone tell me what this means in detail? Should I expect some further problems when working with this option turned off?

Is it even recommendable to turn it off?


Former Community Member
Script scoping rules was adding in version 8.1 (I think). It defines a level of acceptance for writing javascript code. In earlier version you could take short cuts that would not be syntactically correct but would run anyways. If that is checked on the rules for scripting are enforced to the max.

That setting may have something to do with the scoping of your vars....but I am not sure.