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

Export XML (Form with subform and table) and import into database

goslinc
Registered: Sep 25 2007
Posts: 114

I created a form, that has a dynamic table. When I save this form as an xml file, and import to microsoft access, it imports into 2 tables (one holding my form data, and one holding my table data). But I have nothing in the data from my dynamic table that will help me relate that table in acess to the first. So I'm getting all my data with the exception of something that will allow me at the database end, to join these two.

The 1 table coming into the database has my unique identifier (primary key) however, the data being input into the dynamic subform, is not collecting anything that can relate it to the main form.

Please let me know if I need to explain this better.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I see what you are saying, you need a Form ID (your unique identifier) that appears in both places. You have several options. The easiest is to place an invisble field into the repeated subform that is just a copy of the primary key. But you could also transform the XML when it exports from the form.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

goslinc
Registered: Sep 25 2007
Posts: 114
I think I have done that already. When you say invisible field, that field has to have global binding to the primary key yes? When I have done that in the past, I then get neither coming into my database. I get the fields in both spots, but no data in either.
goslinc
Registered: Sep 25 2007
Posts: 114
At this point, this is the specific error I'm receiving when trying to import into the Microsoft Access database:

Row1 xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup" />What am I doing wrong?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
That doesn't seem like a complete error message. Although Access seems to be complaining about the format.

Anyway, Here's how I think you should approach this. Start off by designing an XML grammar that will happily import into Access just the way you want it to. Then connect your form to this xml and bind it to the appropiate form fields. Use scripts in the form to copy data from your main Primary key field into the associated field in the repeatable subform. Don't use global binding.

Another approach is to design two XML gramars, one for importing into Access, and then one that does not include the primary key on the repeated line. Connect the form up to the XML that does not have the primary key on the repeated line. Then bind the primary key field in the repeated subform to the main primary key. So that all primary key fields are bound to the same item in the XML. This is just as good as global binding. Then use an XSLT file on export to transform the Form xml gramar into the Access XML gramar. This can be done right in the LiveCycle form.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

goslinc
Registered: Sep 25 2007
Posts: 114
the other part of the error being received is: Line 27: http://www.xfa.org/schema/xfa-data/1.0/
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Instead of importing the XDP try building your own xml gramar.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

goslinc
Registered: Sep 25 2007
Posts: 114
Thom, I'm so new I don't even know what XDP importing is. I was believing I was importing an XML file or as it appears within LiveCycle Designer, a XFA file. When you tell me to create my own xml gramar I don't know where to begin :-(
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ok, well lets backtrack a bit. When did you start getting the error when importing into Access. Can you get back to the situation where there is no error?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

goslinc
Registered: Sep 25 2007
Posts: 114
Yes the error takes place when importing into access. I'm in acces, file, import, get external data, navigate to the xml file that I saved (as a result of being in the pdf verion of the form and having completed it, doing a form, manage form data, export data). Access then give me a popup showing my form name, but it does not show my table name, which is the holder of this row.
goslinc
Registered: Sep 25 2007
Posts: 114
I better clarify, in the access table that does allow the xml data in, there is a field called Row1 in the database but it is empty.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Was there a time when you did not get the error? Or has there always been an error when you import data into Access?

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

goslinc
Registered: Sep 25 2007
Posts: 114
There was a time (long ago), when I did not get the error. But, instead I got an empty access table, from my form table.

I designed the form, then saved the xml, then went back into the form, and used the previously saved xml file when going into form properties, defaults, data file. Is that much right or wrong?

Thank you by the way for the continued responses.
goslinc
Registered: Sep 25 2007
Posts: 114
Better news, I'm back to the point where I can import into the access database without errros. So, that puts me to the point where you indicated I would have to use scripts in the form to copy data from my primary key into the associated field in my subform/table instead of using global binding.

Any chance you can show me a copy of this?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
How is the primary key filled in?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

goslinc
Registered: Sep 25 2007
Posts: 114
The primary key is filled in by the user completing the form. It is a six digit number that is unique to them. When the user inputs their name, they also input this code early on in the form.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Since it is filled in by the user the copy needs to be in two places or on two actions. First, the copy needs to be activated when the user enters data into the key field so that when the user enters the key the first time, or makes changes at some later time, all of the existing key fields in the repeated subforms are updated. A good location for the copy code is the format event. The second action that needs to be covered is creating a new repeated subform. To handle this a simple copy can be placed in the initialize event for the field in the repeated subform.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Boon
Registered: May 5 2010
Posts: 66
Thomp,

I am able to put the copy script in the initialize event for the repeated field. --> With this setup, when I click "Add" new row, I will have a new value that is in the key field.My question is how should I put the copy script in the key field? What script I should put int he key field's exit event? How do I loop through every row? (says at the beggining, we have 3 rows, but when a user clicks Add, we can have more row...)

thanks,
Boon
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
If you want to perform an action, such as copying data when the value of a field is changed, then you need to select an event that is fired when that field is modified. The validate event works for this, but you have to be careful because Acrobat expects a return value from the validate. Don't use the Exit event, this event is fired when the keyboard focus leaves the field, not when it is changed.

To loop through all the repeated subforms you'll need to use the resolveNodes() function to acquire all fields. You'll find an explaination of how to do this in this video:
https://admin.adobe.acrobat.com/_a200985228/p87746471/

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script