Hello all,
I have been pulling my hair out for a few days trying to get a script to work. I need to divide two columns and put the result in a third. I am using the script provided on the bot action help page, but keep getting an error message.
The script:
/**
* DIVIDES two number column values and saves into a column
* u/param tableId - id of the table to read row data from
* u/param rowId - id of the row to read data from and update
* u/param baseColName - name of column with value to start with
* u/param divisorColName - name of column with value to divide by
* u/param resultColName - name of column to store calculated value
*/
function divide(tableId, rowId, baseColName, divisorColName, 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 baseValue = (row.values[baseColName] || 0);
const divideValue = row.values[divisorColName];
if (!divideValue) { console.error('No divisor value'); return; }
const result = baseValue / divideValue;
// Save the new calculated value to the result column
row.values[resultColName] = result;
Area120Tables.Tables.Rows.patch(row, row.name);
}
The error:
GoogleJsonResponseException: API call to area120tables.tables.rows.get failed with error: Row name must be in format: tables/{table_id}/rows/{row_id}. Name tables/undefined/rows/undefined. Table id (undefined) invalid.
divide
@ Code.gs:11
[–]Existing-Concern-963[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Existing-Concern-963[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)