I am developing a form that includes a button to easily import data from a previously exported xml file.
What I want is to run a code depending of the data loaded. This is a very simplified sample code:
var myCountry=Country.rawValue; //keep current data in a variable
xfa.host.importData("");
xfa.form.recalculate(true);
xfa.host.messageBox("show me the country: " +myCountry, "Error", 3);
//read again
xfa.host.messageBox("new value: " +Country.rawValue, "Error", 3);
The code runs up to the first message, but it seems that it is not allowed to read again any value from the form. So I can not check for the content or compare with the new data, etc.
I know that probably it seems a stupid problem, but I can not get it run. Anybody can help me?
J. Carlos
Solved! Go to Solution.
Views
Replies
Total Likes
Actually it's the same issue as before. You have to make sure that after importData() is called all object references are absolute. In other words it's not enough to simply put MyForm.SomeFunction(), it has to be xfa.form.form1.MyForm.SomeFunction() (or whatever subforms are in between). That's what var somCountry=Country.somExpression; was doing. It was storing the absolute reference before importData() (while relative SOM object referencing still worked).
Kyle
Views
Replies
Total Likes
I still did not find an answer for this issue. How can I run some code after importing data to my PDF and check the value of the imported data?
When I read the imported data it does not work (Country.rawValue above).
J. Carlos
Views
Replies
Total Likes
Ya thats a good one. Once the importData method is called you can't get a relative reference to form objects. You have to use absolute reference.
To fix that create a new variable:
var somCountry=Country.somExpression;
and in your last message box replace Country.rawValue with xfa.resolveNode(somCountry).rawValue
That should do it.
I'd still like to know why the importData() method does that though.
Kyle
Views
Replies
Total Likes
Sorry, I did not understand your proposal regarding how to create that new variable.
Did you mean:
var somCountry=Country;
or
var somCountry=Country.rawValue;
I'll appreciate your help
J. Carlos
Views
Replies
Total Likes
Exactly as it's written in my original post:
"var somCountry=Country.somExpression;"
Kyle
Views
Replies
Total Likes
Oh, yes it works but I have to write that instruction before xfa.host.importData("");
If I write it later, javascript processing stops
There is something strange with that importData() statement, as you pointed.
Other thing it bothers me is that I cannot run any other function after importData
If I just write:
xfa.host.importData("");
xfa.host.messageBox("after import " , "Msg", 3);
MyForm.SomeFunction();
and I have defined
function SomeFunction(){
xfa.host.messageBox("inside function" , "Msg", 3);
}
It shows the first message, but not the second one inside the function. It seems like after importData it does not recognize any variable or function defined inside the form. Is it possible to force to initialize the whole form definitions or something like that?
J. Carlos
Views
Replies
Total Likes
Actually it's the same issue as before. You have to make sure that after importData() is called all object references are absolute. In other words it's not enough to simply put MyForm.SomeFunction(), it has to be xfa.form.form1.MyForm.SomeFunction() (or whatever subforms are in between). That's what var somCountry=Country.somExpression; was doing. It was storing the absolute reference before importData() (while relative SOM object referencing still worked).
Kyle
Views
Replies
Total Likes
Yes, it works now. Thanks a lot Kyle for helping in this strange issue!
I can name more than a dozen of different languages I programmed and I never worked before with such a difficult environment as Adobe LiveCycle Designer + Javascript. For instance, debugging is really a nightmare. This is a sample of what I said: who could think where was the problem? I really appreciate your contribution Kyle.
J. Carlos
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies