Expand my Community achievements bar.

Extensive and dependent forms

Avatar

Former Community Member
Hello everyone.



The scenario is the following:

There is some forms that need to be fill out sometimes by the customer side and others by company side. The initial form will be filled out by the customer and some of those data are required on the another forms.



How could LiveCycle help?



I've seem something about export/import data using XML. How that works?



Thanks in advance!



Diego
12 Replies

Avatar

Former Community Member
I assume that you woudl create two different forms (one for customers and one for companies). If you build them based on the same data structure then you should be able to export/import data from one form to the other.

Avatar

Former Community Member
What do you mean with "same data structure"?

I already have two different forms as you said but they don't have exactaly the same fields, just some of them like Name, Address, Phone.



Thanks



Diego

Avatar

Former Community Member
Any idea?



Actually I have various documents (contracts) that has same data like Name, Address, Phone. And I'd like to fill out just once.



Thanks



Diego

Avatar

Former Community Member
By the same structure I mean if you look at the heirarchy view ten starting with form1.Page1.subform1.fieldnames



All fields that you wantto be the same across all forms should have the same names and structure.

Avatar

Former Community Member
Thanks Paul!



And what more do I need to export data using Adobe Reader?

Avatar

Former Community Member
You will have to submit the data to a server or you will have to Reader Extend the PDF to allow for a local save.

Avatar

Former Community Member
Ok, but that's the point: they are completely different forms and don't have the same data structure.



Example: If a checkbox option was choice on the first form, I need to show or hide a subform and copy some information on the second form.



Is there a way that I can read the XML data by the importData function and do the actions at this second form?



Thanks in advance.

Avatar

Former Community Member
You could load the data into the data dom but beacuse the data is not bound to any fields in the data you will have to interrogate the data dom to find th evalues that you want. This is doable but it will require soem signicant code. Do you have any programming experience? If not I would not attempt this. If so I can help you. Let me know which way you want to go.

Avatar

Former Community Member
Paul,



I have that skills, actually I've been working with many languages involving web development like Javascript, PHP, Java and now Javascript in LC Designer.

Could you tell me the way I need to follow to achieve the solution?



Thanks again!



Diego

Avatar

Former Community Member
You can use xfa.datasets.data.loadXML(xml to load, param1, param2).

Where param1 is a boolean value that indicates whether the root node of the Dom should be ignored, in this case the children will appear under the root node. False if the root node of the incoming XML should be appended to the current Dom Root. Param2 is also a boolean that indicates whether to replace the current content or not.



You should not overwrite the current Dom as that is what is being mapped to your loaded form. So put the imported data into a new node.



Now that it is loaded you can place a large multi-line field on the form and you can dump the dom into that field to see what it lookslike. To do this use: BigField.rawValue = xfa.datasets.data.exportData("pretty"); Put this on a button so you can be sure that everything is set up before you check the Dom. The pretty flag is only used to make the XML more readable.



Now that we know what the Dom looks like we can now start using it.We simply navigate our way to the node(s) that we want. To access individual nodes you can use expressions like this:



var test = xfa.datasets.data.form1.Page1.Field1.value



Note the use of the value property and not the rawValue when dealing with a node in the DOM. If you want to deal with multiple nodes



var objs = xfa.datasets.data.form1.Pag1.nodes



Now we can look at the length of objs to know how many nodes we have and you can loop through the objects using objs[i] notation.



This should be enough to get you going.

Avatar

Former Community Member
That is the information I was looking for.



I'll do this and the next doubts I'll post here.



By the way, is there any other paper, tutorial or sample I can follow?



Thanks Paul.

Avatar

Former Community Member
Not to this detail. There is a scripting reference that describes the individual commands but that is it.