/
Row Level Calculations In Tables

Row Level Calculations In Tables

In some cases, it can be helpful to be able to perform calculations in the rows of tables. Live Field rules allow for complete access to the row/column details of table data attached to a document. In this example, we calculate the Extended Amount bases on Quantity and Amount fields in a row.

Note that table field arrays are zero based, meaning the column indexes start at zero. In the example below, row[0] represents the field field in the table field (Quantity).

// Get current values. var tf = $$inject.tableFields['Line Items']; // Manipulate the data. var data = tf.$$rawData(); tf.$$clear(); data.forEach(row => { var extended = row[0] * row[2]; if (extended == 0) return; row[3] = extended; tf.$$add(row); }); // Set the LiveField output display value. return 'Updated ' + tf.$$rowCount + ' rows.';

Related content

Live Fields
Live Fields
Read with this
Sum Table Field Values
Sum Table Field Values
More like this
Warn on blank field
Warn on blank field
Read with this
Looping Through Datagrid Items
Looping Through Datagrid Items
More like this
Geolocation
Geolocation
Read with this
Looping Through Datagrid Items (GlobalForms versions < 10.1)
Looping Through Datagrid Items (GlobalForms versions < 10.1)
More like this