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

dynamic subforms - instances and global function problem

gc123
Registered: Feb 11 2010
Posts: 7

Hi,
I am trying to create a dynamic subform which has the following layout.

page 1 - is a summary page with a parts list.
page 2 - (onwards) are individual pages detailing the specification of each part.

When the user adds a part on the summary page, the parts list grows and a new part detail page is added on to the document. When the user deletes a part, the part list item is deleted and so is the relevant part detail page.

I have created this using the instance manager, i.e. adding and deleting rows and pages.

Since the summary page repeats data, I want some of the information from the part details page to be automatically copied into the summary 'part details' list.

I have tried using the global function but this doesn't seem to be able to handle the difference between new instances. - it thinks they are all the same as each instance cell name is the same.

I have also tried many variants of:

xfa.resolveNode("form1.mainpage.PartsList.PartsOptions[0].PartsName").rawValue = form1.ContentPageSF.TextField1.rawValue;

This code refers to a text box in the part detail page, any data entered into this cell is copied into the parts list on the summary page. This works but only for the instance selected in the [ ] .

I want the code to be able to work for any instance.

I.e if the user has created a second part I want the data in both the first part and second part to be copied back to there relevant instance row on the summary parts list page.

Is this possible?

Do I need some type of counter to enter into my [ ] ?
Can i use anything other than a number in [ ] ? i.e could i calculate the instance I am on, then call it something like numberinstance then use put this in brackets like [numberinstance]?

alternatively is there a way to rename new cells in new instances so that I could use the global functions?

I hope this makes sense,

Many thanks in advance!

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes this is possible. It's all a matter of how it is coded, and where the code is located. Since this code needs to affect a specific instance of a field, it should be placed in the repeated subform. Probably on the change event for the field that selects the part. Then it can simply reference "PartsName", and it will always get the correct instance.

This is a general rule. Code that affects a specific instance of a field should be placed in the repeated subform where that field exists.

But, there are many other solutions. For example the "addInstance()" function returns the newly created subform. You can use this to reference the new field at the time it is created.

How it's done depends entirely on the configuration of your form and the desired workflow.

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