Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Auto-update calculation field in expanding table when line is deleted?

Avatar

Former Community Member

I have an expanding table that allows adding and deleting rows. There is a grand total cell that accurately calculates the total. The issue is that, when I delete a row, the grand total does not update unless I make a change to one of the applicable cells in the remaining rows. How do I set my Grand Total cell to automatically recalculate when the Delete Line button is clicked?

1 Accepted Solution

Avatar

Correct answer by
Level 7

So as we discussed offline your code is good. The issue is that you are viewing the file with PDF X-Change. I have reached out to them and they have acknowledged that this is not working in their software. They claim it will be fixed in an update.

View solution in original post

11 Replies

Avatar

Level 7

Not a difficult thing to do but i would suggest looking at Adobe's Tutorials, they gave me a great start into the world of LiveCycle.

Creating a Purchase Order Form - http://help.adobe.com/en_US/livecycle/9.0/lcdesigner_qs_poform.pdf

This one is what you after, you create a table with adding and removing rows with calculated amounts.

Creating a Purchase Order Form That Has a Flowable Layout - http://help.adobe.com/en_US/livecycle/9.0/lcdesigner_qs_poformflowable.pdf

Avatar

Former Community Member

Hi MinusZero,

Thanks for your suggestion. I actually have a working expandable table with a calculated sum. The issue is, if I delete a line using my delete line button, the sum doesn't recalculate (and subtract the missing row's value) unless I then edit a remaining row. I've taken a look through Adobe's Tutorials, but I can't seem to find anything to address this issue.

Thank you!

Avatar

Level 7

Hi,

The calculated sum should change as long as the code is correct and in the right place.

In the flowable tutorial the Sub Total field has sum(Table.Table1.Row1[*].amount[*]) in it's FormCalc calculate event. Calculate event code continually calculates as things change in the form. When you click a button to remove a row, the amount should change.

In this example, the amount is summed and added to the SubTotal. The * adds all items in the column. Code isnt needed in the delete row button in this instance. The code in the calculate event does it all for you.

1299267_pastedImage_0.png

Avatar

Former Community Member

Hi MinusZero,


Thank you. I am not sure why mine does not automatically recalculate. As far as I can tell I have it set up properly. See below. Footer Total Script.PNG

It automatically recalculates when I add a line, but it does not when I delete a line.

Avatar

Level 7

Hi,

That is a strange one, I have done a few tests and it worked. What i can suggest is try to target the field location more directly like you would with this.resolveNode.

It is slightly different with formCalc.

Instead of

sum(PurchaseOrderTable.Row1[*].ExtendedCost[*])

try

sum(xfa.form.form1.#subform.PurchaseOrderTable.Row1[*].ExtendedCost[*])

1302422_pastedImage_0.png

Avatar

Level 7

On the delete row button you will need to use a recalculate action. Use this below the delete code:

xfa.form.recalculate(1);

This will force a recalculation and should solve the problem

Avatar

Former Community Member

Thanks! I tried this. Unfortunately no change.

Avatar

Former Community Member

Hi mouslander,

I already have that code in my delete button?

Delete Button Script.PNG

Avatar

Level 7

do you want to send me the file? I can look at it for you. mousland@gmail.com

Avatar

Level 7

No move it below the "}" now it will only trigger if the condition is met.

Avatar

Correct answer by
Level 7

So as we discussed offline your code is good. The issue is that you are viewing the file with PDF X-Change. I have reached out to them and they have acknowledged that this is not working in their software. They claim it will be fixed in an update.