Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Total of Field in dynamic Sub Form with certain condition

Avatar

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 ?

Thanks,

1 Reply

Avatar

Level 10

Hi,

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,

Niall