Skip to main content
upsertRows matches each input record by one or more exact header columns, patches existing matches, and appends new keys.

Example

Inputs

spreadsheet, source, non-empty exact keyColumns, and one or more records are required. Every input record must have a non-null value for every key; partial non-key fields patch existing rows, while omitted fields become null on new rows. inputMode defaults to userEntered. account optionally selects the Google account binding.

Output

Returns { affectedCells, insertedRows, insertedRange?, updatedRowNumbers }. insertedRange is available for ordinary sheets, not native tables. The action fails when existing rows share a composite key or input records contain duplicate keys, preventing ambiguous updates.