Adding Columns in Google Tables

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:

 

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.
add @ AddColumns.gs:11
 
Any suggestions?  
1 0 192
0 REPLIES 0
Top Labels in this Space
Top Solution Authors