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

AddInstance and setting field values

michelleny914
Registered: Sep 1 2009
Posts: 11

Hi,
I'm having an issue with one of our forms. It was created in Livecycle as a dynamic pdf. If's a 4 page document, wth page 4 having a button to allow the user to add additional supplement pages. The button is coded as follows:
_Page4.addInstance(1);
I've created a sample xml file and have set the data binding to all the fields in the document. On page 4 I have set the property "Repeat subform for each Data Item" with the min value set to 1.
 
Problem - If the user adds data to page 4, then presses the Add Page button, all the data that was entered in the original Page4 is duplicated in any and all additional supplement pages. How can I stop that from happening?
 
I did try and setting the "Repeat subform for each Data Item" property for all items (tables, cells, etc..) that contained a data field. That didn't work, same results. Is there a way to get around this issue? Is it because I set the data binding to a xml file?
 
Secondly - If my studying is correct, to access the first instance on a page I would use something to the affect form.form1.Page4[0].Field1, right? If it is a instance of another page, do I have to add the [0] to every node of the tree? for example:
form.form1.Page4[0].Cell1[0].ClientName[0]
 
Another option I though of was to rename all the fields in the new instance of the page, then fill the new instance using the new field names. Is this possible? I though doing so could eliminate the duplicate data in the new instance of the page.
 
Thanks for any help or suggestions.

My Product Information:
Acrobat Pro 9.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
When a set of fields in a subform are repeated, they are expected to be connected to a set of repeating nodes in the data connection. The most likely problem you are seeing is that Acrobat is not recognizing the set of nodes in the XML connection as repeated, so the repeated fields on the form are pullling data from the same node set in the data model.

Take a look at the binding for repeated subform. It should be something like $record.Data[*], where Data is the path to the Repeated node in the XML. The [*] notation tells acrobat that this is a repeated data set, that it bound to mulitple instances of the data. Then the fields inside the repeated subform are bound to the XML nodes using a relative notation, i.e., they don't reference $record.Data, but instead are just the name of the XML node.

The [] notation used in the SOM path for accessing an instance of a form element is only necessary when the index is not zero.

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