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.

Autosum totals for amounts in multiple instances of table?

Avatar

Level 2

I'm using LiveCycle ES2 to create an expense claim form. I have no trouble calculating the sum of all values in a column in a table with repeatable rows. However, this form is more complex. As you'll see, each item (expense) is a table. Clicking the button adds a new instance of the table. No problem with the calculation for GST, either.

item.jpg

Where it gets tricky is trying to dynamically calculate the grand totals for all expenses incurred and for all GST. This is in a different table, as you can see here.

totals.jpg

And here's a grab of the object hierarchy that illustrates just how I built this.

hierarchy.jpg

Is this too complex, or is there a way to dynamically calculate the grand totals, regardless of how many instances of ExpenseDetails there may be?

12 Replies

Avatar

Level 10

Nothing is too complex to calculate, using FormCalc should help you big time!

Using formCal for every instance should look something like this :

Sum($.resolveNode("ExpenseDetails").Row1[*].GST)

Row1[*] specify every instance of the object

Avatar

Level 2

Hello, Magus069, and thank you for the reply. As you can see, however, it doesn't achieve the desired result.

multiple.jpg

Avatar

Level 2

Unless I misunderstood your post, I put the line of code provided in the GST cell of the Labels row in the Totals table.

code.jpg

This illustrates the table, and that it's configured to be repeatable.

repeatable.jpg

As indicated earlier, the Add/Delete buttons add/remove an instance of the entire table.

Avatar

Level 10

I am not sure if this could fix it... but you might want to name your Subform that contains ExpenseDetails other than the table's name itself...

Code your AmtExclGST total too in the same way of your GST to see if there's any difference

Avatar

Level 2

This doesn't appear to make a difference.

Avatar

Level 10

Can you make another screenshot of the result, and use different values

Avatar

Level 10

Oh!!! okay geez, you create instance of your table with you parent Subform or with your table?

When you click Add Row, you are using instanceManager.addInstance(1) or insertInstance(x), when you write your calculate code line you must input this [*] on the object that you add instances too

Avatar

Level 2

If Add row is clicked, add a new instance of ExpenseDetails table. Conversely, if Delete row is clicked, remove current instance of ExpenseDetails table.

These actions were built using the Action Builder, not code.

Can you let me know where the wildcard, [*], goes?

Avatar

Level 10

can you show me the code written in add row click?

If I understand, it should be something like so:

Sum($.resolveNode("frmExpenseDetails").ExpenseDetails[*].Row1.GST)

but seeing you add row code should help, even if the action builder did it for you, there's should be some code in the click event

Avatar

Level 2

Note that I've renamed the subform:

hierarchy2.jpg

The code for the AmtExclGST is:

Sum($.resolveNode("ExpenseInfo").ExpenseDetails[*].Row1.AmtExclGST)

And the code for GST is:

Sum($.resolveNode("ExpenseInfo").ExpenseDetails[*].Row1.GST)

This worked!

totals3.jpg

Thank you very, very, very much!