Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Total of Field in dynamic Sub Form with certain condition


Level 2

Hi Experts,

Sorry for beginner question.

I have dynamic sub form (add/remove button) with 1 drop down field and 1 decimal field.

User can add/remove the subform dynamically.

Now i want to summarize the decimal field only if the drop down field = "A".

1. How to get the no of the final subform(s) ?

2. How to summarize the decimal field based on certain condition ?


1 Reply


Level 10


This does involve a couple of methods, but is achievable. Have a look at example 10 in this form as a demo: http://assure.ly/kUP02y.

The JavaScript in the click event would look something like this:

// set up a variable

var vTotal = 0;

// resolve the row objects in the table

var nRows = xfa.resolveNodes("Table1.Row1[*]");

// set up a loop to go through the repeating rows

for (var i=0; i<nRows.length; i++)


     if (nRows.item(i).CheckBox.rawValue == "A")


          vTotal += nRows.item(i).DecimalField.rawValue;



// set total field

this.rawValue = vTotal;

Note that you will have to change the object references Table1, Row1, Checkboc and DecimalField to suit your object names.

Hope that helps,