Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to copy all data from repeating subform to second repeating subform

Avatar

Level 1

I have a repeating subform on P1 that will have varying number of lines created.  Then on P4, I have another repeating subform, with the same fields, that data from P1 subform needs to be copied into.  I have tried many things, but my skill level is not too great so none of them have worked entirely.  I have a partially working script on a button named CopyAll, but it is not very elegant and throws an error message when it hits the end of the number of lines that have been created on the P1 subform.

Can anyone suggest either a fix to this script or a better method of scripting?  I think this must be a tough one, since anything I have found on the forums that are similar to this one have not been resolved either.  I have attached a copy of my form.

1 Accepted Solution

Avatar

Correct answer by
Level 4

In the event Exit of the 1st subforum.invoice you will find the code to assign the value to it's "brother" on page4.

Also, on the add button i added the code to add a record to the page4 subforum.

To make this work you will have to copy/past 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.

I didnt't do anything to te remove line button because i don't know how you want it to work, but, if you want to control the p4 subform with the p1 subform, you shouldn't allow for lines to be removed directly in the p4 subform.

Hope this helps.

View solution in original post

4 Replies

Avatar

Level 4

This is a rought version of it, but you check if the invoice behaviour is what you want.

Avatar

Level 1

Yes that works.  Where did you put the script?  How do I get it to work for the other fields?

Avatar

Correct answer by
Level 4

In the event Exit of the 1st subforum.invoice you will find the code to assign the value to it's "brother" on page4.

Also, on the add button i added the code to add a record to the page4 subforum.

To make this work you will have to copy/past 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.

I didnt't do anything to te remove line button because i don't know how you want it to work, but, if you want to control the p4 subform with the p1 subform, you shouldn't allow for lines to be removed directly in the p4 subform.

Hope this helps.

Avatar

Level 1

YOU DID IT!! I had almost given up.  Thanks so much!