I have tried that setting and am still having the same issue.
Is there any other way to save a variable in a document that can be accessed in the future, without using the Global object. Or am I just using it wrong?
Thanks for the speedy reply, much appreciated.
The easiest way to save a value in a document is to set the value of a form field, which can be hidden or on a hidden template page. It's hard to say why you're having the problem you are without knowing exactly what you're doing.
Ok so in 'Document1' I ask someone to type they're name in a Form Field. I then run global.SavedName = getField("Name").value;
The problem is in 'Document2' if I run getField("Name").value = global.SavedName the Global Variable is pulled in from Document 1.
This is a major issue in my case and can corrupt the information in the documents. Is there a way to keep the global variables I save private to each document not accessible to every PDF document I open.
What should happen when you use getField("Name").value = global.SavedName in 'Document2'?
That's the entire point of a global variable... Use a doc-level variable
The last section ("When not to use the global object") talks about it's limitations, and makes recommendations for storing document specific data. One option is the field, as was already mentioned in the comments, another option is to store the information in custom meta data (which will not be an option if your solution also has to work with the free Adobe Reader).
Thank you all for you input.
* Bernd Alheit
When that code is run in Document 2 it should load the value of what is in the Name Field in that Document, not a different document.
The problem is if I use doc-level variable the data is not saved/remembered if the document is closed and reopened. Is the only workaround to store the values in hidden text fields?
*Karl Heinz Kremer
Thanks for the link. As above, I'm thinking storing data that needs to be remembered will have to be in hidden text fields ideally?
A global variable won't do that, either, unless you set it as persistent,
and even then it will only be on your machine.
The suggestion to save the value in a field, or a metadata tag, is the best
You can use different global variables for different documents.
Thats what I thought.
I don't have persistence set to enable on the Global Variable. So why is the Global Variable accessible from a different PDF document at the same time?
When persistence is enabled the value of the global variable is stored on your system. Then you can access the variable after a restart of Adobe Acrobat.
Right, but I don't have it enabled. It doesn't make sense why Document 2 can see Documents 1's global variables if I didnt persist the global variables?
That's not it means. Read the previous reply more carefully.
A global variable is global in the application. You can't have different values for the same global variable in the application.
1 person found this helpful
There are two options if you want data to remain persistent with in a document context.
1. Write the data to a form field, that is what they are good for.
2. Write the data to the "info" object. This is the same as the data set on the "Custom" tab on the document properties dialog