Syntax for batch update

119 views
Skip to first unread message

IK

unread,
Jan 19, 2025, 2:00:43 PMJan 19
to Google Apps Script Community
I'm trying to use the Advanced Service to perform a batch update and running into some issues. I have a table named "accounts" that I'm trying to write to my sheet. It's going in cells N8:Q10. However I am getting an error that is preventing the update from occurring and I'm not sure how to address it. See the error below. I think it's how I'm setting up the accounts table in the rows field but I'm not sure what to do to fix it.

accounts = [["test", 1, 2, 3,],  ["test1", 4, 5, 6], ["test2", 7, 8, 9]];
const response = Sheets.Spreadsheets.batchUpdate({
  requests: [
    {
      updateCells: {
        range:
        {
          sheetId:          0,
          startRowIndex:    7,
          endRowIndex:      10,
          startColumnIndex: 13,
          endColumnIndex:   17,
        },
        rows: accounts.map(e => ({ values: e.map(f => ({ userEnteredValue: (isNaN(f) || f == "" ? { stringValue: f } : { numberValue: f }) })) })),
        fields: "userEnteredValue"
      }
    }
  ]
}, getID());


GoogleJsonResponseException: API call to sheets.spreadsheets.batchUpdate failed with error: Invalid JSON payload received. Unknown name "numberValue" at 'requests[4].update_cells.rows[2].values[2].user_entered_value': Proto field is not repeating, cannot start list. Invalid JSON payload received. Unknown name "numberValue" at 'requests[4].update_cells.rows[2].values[3].user_entered_value': Proto field is not repeating, cannot start list.

Reply all
Reply to author
Forward
0 new messages