Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments

Strange issues with global variables


Not applicable

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 = ...; 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


Level 10
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.


Not applicable
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?


Level 10
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.