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

Cycling through dynamic subforms

Dripto
Registered: Jun 20 2007
Posts: 47
Answered

Hi,

Our software takes in an XDP form that has a subform called rfqDetail and generates a PDF with multiple instances of that subform (based on the user's requirements). The rfqDetail subform has a quotePrice field in it that contains a decimal value. The form also has rfqFooter subform which only appears once in the PDF.

What I have so far is a Calculate button in the rfqFooter subform and a totalPrice decimal field which will calculate the sum total of all the quotePrice fields in all the rfqDetail subforms once the user clicks the Calculate button.

My script so far is as follows:
for (var i = 0; i < rfqHeader._rfqDetail.count; i+){

xfa.resolveNode("rfqFooter.partsTotalA.rawValue") = xfa.resolveNode("rfqHeader.rfqDetail["+i+"]").volA.rawValue + xfa.resolveNode("rfqFooter.partsTotalA.rawValue") ;

}

Can anybody explain why this isn't working?

Thanks

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
There is an example in the Scripting Reference Manual of Designer, that maybe useful for you!
// Access a field in a repeating subform by looping through the node list.var oFields = xfa.resolveNodes("Subform2[*].NumericField4");var nNodesLength = oFields.length;var nSum = 0;for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {nSum += oFields.item(nNodeCount).rawValue;}TextField1.rawValue = nSum;

You will need to modify the script for your needs like this (I didn't test it so far).

var oFields1 = xfa.resolveNodes("rfqFooter[*].partsTotalA");var oFields2 = xfa.resolveNodes("rfqDetail[*].volA");var oFields3 = xfa.resolveNodes("partsTotalA[*].partsTotalA");var nNodesLength = oFields.length;var nSum1 = 0;var nSum2 = 0;var nSum3 = 0;for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++){nSum1 += oFields1.item(nNodeCount).rawValue;nSum2 += oFields2.item(nNodeCount).rawValue;nSum3 += oFields3.item(nNodeCount).rawValue;}TextField1.rawValue = nSum1 + nSum2 + nSum3;

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Dripto
Registered: Jun 20 2007
Posts: 47
Terrific!!! That worked.