Level 1

0% to

Level 2

Tip /

to gain points, level up, and earn exciting badges like the new
Mission!

View all

Autosum totals for amounts in multiple instances of table?

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.

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.

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

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?

0 Replies

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

Level 2

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

Level 10

Can you show me your code?

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.

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

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

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

Level 2

This doesn't appear to make a difference.

Level 10

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

Level 2

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

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?

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

Level 2

Note that I've renamed the subform:

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!

Thank you very, very, very much!