Calculation on dynamically added rows in a Table
Among many features that PDF provides, auto calculation of form fields is a very useful feature. Apart from the usual mathematical calculations, this feature can be exploited to calculate table rows based on data at runtime.
Use Case
Consider a scenario where the data is generated and fed to the table. The table must accommodate the incoming data dynamically at run time. It is imperative to determine the additional number of rows in the table as per user requirement at the same time.
How will we calculate to reflect the dynamic objects and how to reference these values?
This article will help you to accomplish the task.
Solution
We use the following script:
FormCalc Script: sum(Table1.Row1[*].total.rawValue)
There are two essential things to be kept in mind to make the script work:
- Choose the script language as FormCalc in AEM Forms. By default, it is set to JavaScript.
- The FormCalc function sum() is simple to use. Make sure you know the object (that is, either the row or field) that is getting added dynamically. The [*] symbol is appended to the row which is getting repeated or with the field name if required.
In our use case example, only the row is repeating. So, we have not provided any value to the field.
For additional queries, please send your form to lcdesignerforms@gmail.com
Download the sample file from https://www.dropbox.com/s/07c5591nay1xetl/CalculationOnRows.pdf?dl=0
No comments:
Post a Comment