Calculating sums in JavaScript

Sometimes it is useful to be able to calculate the total of a field across a table without running through all the records like the Rec.Calcsum() function does in AL.

To do this, you can simply use the Sum value on a FieldExtension field:


If the field is a calculated field, Business Central will use that to calculate the sum, otherwise it will iterate though the records to calculate it.

Any filters set on the record are used for the calculation.