Wednesday, 19 April 2017

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 the data at run time.

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. And you determine that you must add few more 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:


  1. Choose the script language as FormCalc in LC Designer. By default, it is set to JavaScript.
  2.  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 for the field.


For additional queries, please send your form to lcdesignerforms@gmail.com



No comments:

Post a Comment