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

button that copies all data in repeating subform fields to 2nd subform

suewhitehead
Registered: Jun 3 2008
Posts: 232
Answered

I am trying to make my form so that a button will copy all entries that are in repeating subform A into the same fields in repeating subform B. I have a possible script but it throws an error message when there is not another line in subform A. For example if I have 2 sets of the subform A, the button will say that P1.invoice[2] (the third set) cannot be found. The script does copy and paste the data into the correct fields in subform B.
Here is a shortened version of my current script:

//if the [0] row exists in the first dynamic itemset, then copy the data from it into the second dynamic item fields.

var copy0i = form1.P1.ItemSet[0].Invoice.rawValue;
var copy0a = form1.P1.ItemSet[0].Amount.rawValue;
if(Exists(form1.P1.ItemSet[0].Invoice))
then
form1.ItemSetPage.Return.ItemSet[0].Invoice.rawValue = copy0i
form1.ItemSetPage.Return.ItemSet[0].Amount.rawValue = copy0a
endif

var copy1i = form1.P1.ItemSet[1].Invoice.rawValue;
var copy1a = form1.P1.ItemSet[1].Amount.rawValue;
if(Exists(form1.P1.ItemSet[1].Invoice))
then
form1.ItemSetPage.Return.ItemSet[1].Invoice.rawValue = copy1i
form1.ItemSetPage.Return.ItemSet[1].Amount.rawValue = copy1a
endif

var copy2i = form1.P1.ItemSet[2].Invoice.rawValue;
var copy2a = form1.P1.ItemSet[2].Amount.rawValue;
if(Exists(form1.P1.ItemSet[2].Invoice))
then
form1.ItemSetPage.Return.ItemSet[2].Invoice.rawValue = copy2i
form1.ItemSetPage.Return.ItemSet[2].Amount.rawValue = copy2a
endif

If anyone can either (1) correct this script so that it works but without the error message or (2) suggest a different approach to scripting it, I would really appreciate it.

My Product Information:
LiveCycle Designer, Windows
suewhitehead
Registered: Jun 3 2008
Posts: 232
I found out how to do this. Wanted to post it so others can do it too.

In the event Exit of the 1st subforum.invoice you will find the code to assign the value to it's "brother" on page4.
xfa.resolveNode("form1.P4.ItemSet("+this.parent.index+").Invoice").rawValue = this.rawValue;


Also, on the add button I added the code to add a record to the page4 subforum.
form1.P4.ItemSet.instanceManager.addInstance();


To make this work you will have to copy/paste the code of the exit event to all fields you want to copy and in the xfa.resolvenode("XXXXXXX[].fieldName") command replace fieldname with the actual name of the field you're at.

If you want to see the sample forms, you can go to http://forums.adobe.com/message/2059910.