You are viewing limited content. For full access, please sign in.

Question

Question

Not a normal calculation...

asked on September 11, 2017

Good morning from Arkansas!!

I have read the help document on using calculations in forms with JavaScript. I have a unique situation I would like to calculate that I can't seem to figure out. Unfortunately it does not fit within the scenarios covered in the help doc.

I have a repeatable collection with fields (price, quantity, subtotal) that each repeatable section has. I then want to SUM each subtotal to a grand total outside the repeatable section. The closest I can get in the help doc is the repeatable table with tax, shipping, and total outside the table. I don't have tax or shipping so the JavaScript isn't working.

Any help is greatly appreciated!

 

0 0

Answer

SELECTED ANSWER
replied on September 11, 2017

You need to index both cost and quantity before calculating the product so:

=PRODUCT(INDEX(collection.price,ROW()),INDEX(collection.Quantity,ROW()))

 

 

Then in Grand total:

=SUM(collection.Currency)

 

and here is a demo of the result:

3 0

Replies

replied on September 11, 2017 Show version history

In Forms 10 you can use built in formulas on the fields. Here is the URL: https://www.laserfiche.com/support/webhelp/Laserfiche/10/en-US/administration/#../Subsystems/Forms/Content/FieldCalculations.htm 

I'm guessing in the Subtotal field you would do =PRODUCT(collection.price,collection.quantity)

Then in the Grand Total field you would do =SUM(collection.subtotal).

The "collection" word would be actually the name of your collection, followed by a dot and the variable name of the field.

The fields doing the calculations have to be "Number" or "Currency" type.

LFFormulas.PNG
LFFormulas.PNG (14.18 KB)
0 0
replied on September 11, 2017

The normal field calculations do work. The only issue here is the repeatable collection. When I ADD a new set of data, the calculations no longer work properly.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.