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.

How do you total a column of rows that are not repeating and may get deleted?

Avatar

Level 1

I am new to livecycle and javascript.  I have managed to create a form with 9 rows.  Each row has a button to add a new instance of the row and to delete the current instance.  Each row has numeric field titled "Amount".  Because my rows have different names, the "Amount" in each row is not binded therefore the calculation below will not work:

sum(Amount[*]);

Instead I am using the more specific sum formula below:

sum(Table1.Product1[*].Amount[*], Table1.Product2[*].Amount[*], Table1.Product3[*].Amount, Table1.Product4[*].Amount, Table1.Product5[*].Amount,  Table1.Product6[*].Amount, Table1.Product7[*].Amount, Table1.Product8[*].Amount, Table1.Product9[*].Amount);

My issue is that once a row is deleted from my form, the sum no longer works because it is looking for that deleted row.

Does anyone know a better way to do this?  Is there a simpler format for my sum calculation or is there a way to have it check to see if the row exists and if it does not exist  just set it's value to 0 so the calculation still works?

Thank you in advance!

help.JPG

2 Replies

Avatar

Level 10

Hi,

Rename all your table rows with a single name e.g Product (not Product1, Product2 etc.)

And write your formcalc script as:

I hope this will work.

If you still find any difficulty, please send me your form nith.mof@gmail.com

Nith

Avatar

Level 1

Thank you Nith.  However, I'm not sure if that will work for my form.

I have the rows named differently because that was the only way I was able to make the delete buttons in each row work correctly.  The difference between my form and the Adobe's Add or Remove Row Example is that I would like to have prepopulated rows.  Basically, I want the form user to start with a finished quote and then make minor changes like adding or removing rows or editing the text.

I sent you my form so you can take a look.