These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Document-level variable not set correctly

rclarkin
Registered: Jun 10 2010
Posts: 3

I am having trouble getting a document-level variable to "stick" after it is populated. The scenario is as follows:
 
In document-level script I have a couple of arrays:
 
Array 1 is a list of funds, for example:
 
var arrFundList = [["Code 1","Name English 1","Name French 1"],
["Code 2","Name English 2","Name French 2"],...
["Code 123","Name English 123","Name French 123"]];
and
var arrDocList = [[" ",""]];
 
There is also a function, fn_buildFundSelects() that when called does something as follows:
 
strLang = (this.getField("language").value == "French")?"F":"E";
for (var i=0;i<arrFundList.length;i++) {
arrDocList.push([(strLang == "F")?arrFundList[i][2]:arrFundList[i][1],arrFundList[i][0]]);
} // end FOR
 
The above loads the arrDocList array with fund information in either French or English and the export value equal to the fund code.
 
After the above, the value of a set of drop-down selection fields is set to the content of this array:
 
this.getField("select_1").clearItems();
this.getField("select_1").setItems(arrDocList);
 
This is repeated for each fund selection combo box on the form. The initialization function is executed by the Page.Open event. All of the above code works great and correctly populates the combo boxes.
 
The issue that I'm having is that the content of the document-level variable, arrDocList, is not retained. When I later try to reference it using some field-level scripts, it does not contain the expected 123 (or however many) number of elements but only contains the value that it was originally defined with.
 
Everything that I have read indicates that updates made to a document-level variable should be retained for the life of the document, making them global within the document; however, the behavior that I'm seeing makes it appear as if I'm running into some kind of scope limitation (of which I'm not aware). Any pointers to where I might be going wrong here would be GREATLY appreciated.
 
Thanks!
Rick

My Product Information:
Acrobat Pro 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
It will be retained unless it gets reset somewhere. I would begin by looking to see if some other code sets it back to the original value.
rclarkin
Registered: Jun 10 2010
Posts: 3
The only place that the code setting the value is called is on page load and *that* execute is wrapped in code to check to see if it has already run. So, I'll keep looking. In the interim, I've made the array a property of the global object which works well and allows me to access it how I need to, at least with 1 PDF open. Still need to test what happens if I've got more than 1 PDF open at the same time since I want it restricted to the document vs. the user session.

Anyway, for now I've got a solution -- not what I was hoping so, but it'll work in a pinch. I'll update when I find additional info on this issue.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Maybe there's a bug in your wrapping code. You could post that as well.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com