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.';
CODE