I am facing very strange behaviour when declaring local variables in Script Object under the main form (form1), as well as under an inner subform.
I have used this method always, and it works like a charm. I declare a variable in a script object, and initialize it using an initialization function as follows:
//Script Object "scTest"
var testVar;
function initialize() {
testVar = "New value";
}
function printTestVar() {
console.println("testVar = " + testVar);
}
Then, in the init event of some element in the main form, I call the function as follows:
scTest.Initialize();
Then later, any reference to this variable "testVar" will have the value "New Value". For example, if I call the function "printTestVar()" on a click of a button it will print "New Value".
I created the sample PDF attached in the link below. This file works as it should. However, I have one legacy form that is not working is such. It seems only this legacy form has this problem, and I am unable to find out why. Basically, some time, when the I call the function "printTestVar()" the variable declaration is executed again, and the value of "testVar" will become "undefined". Unfortunately, I cannot send this form for testing by others.
I am wondering if anyone has faced this problem and how to troubleshoot what is going on.
Variables in Script Object.pdf