Skip to main content
Kofax

How To Run Calculations On KTA Table Cell Field Values

3018151

Question: 

I would like to be able to run simple calculations on TotalAgility (KTA) table cell field values on a form. For instance, multiplying a value in one cell by a unit price in another cell to get the total price for the line.

Solution: 

This can be done a few different ways. The normal approach would be to extract the field values, and then run calculations using business rules in field validation.

Another option could be to use a Database Query action to populate a custom database table with the table data, then using another Database Query action to run a Stored Procedure to perform the calculations and return the Stored Procedure value back to the form. 

Another option would be to use a javascript action. Here is an example of a script to use. The script action could be called in the "OnTableCellConfirmed” event or from a button clicked event.

 

var field = thisForm.controlManager.getControlByName("TableTest");

var RowSelected = field.selectedRow;

var colA = parseInt(thisForm.controlManager.getControlByName("TableTest").kfxData.field.table.rows[RowSelected].cells[0].value);

var colB = parseInt(thisForm.controlManager.getControlByName("TableTest").kfxData.field.table.rows[RowSelected].cells[1].value);

var totalAB = colA + colB;

field.setCellValue(RowSelected,"TOTAL", totalAB);

 

This script takes the value from column A and adds it to column B and provides the calculated total in a "TOTAL" column. The script can be adjusted to suit your requirements.

 

Applies to:  

Product Version
KTA All