I understand that there is no native adding of columns in Google Tables.
I have tried to create the appscript per the instructions using using:
/**
* ADDS two number column values together and saves into a column
* @PARAM tableId - id of the table to read row data from
* @PARAM rowId - id of the row to read data from and update
* @PARAM firstColName - name of column with first value
* @PARAM secondColName - name of column with second value
* @PARAM resultColName - name of column to store calculated value
*/
function add(tableId, rowId, firstColName, secondColName, resultColName) {
// Get the row of data from the table, make sure it exists or abort
const row = Area120Tables.Tables.Rows.get('tables/' + tableId + '/rows/' + rowId);
if (!row) { console.error('Row does not exist'); return; }
// Do the calculation with the values from the columns
const firstValue = (row.values[firstColName] || 0);
const secondValue = (row.values[secondColName] || 0);
const result = firstValue + secondValue;
// Save the new calculated value to the result column
row.values[resultColName] = result;
Area120Tables.Tables.Rows.patch(row, row.name);
}
I have received this error when I run it and I can't figure out how to resolve it. I tried changing the values to row_id and table_id, tried putting { } around each like it suggests but keeping getting variations of the same error: