← Back to blog

n8n Google Sheets: Match IDs and Update Designated Columns

Build an n8n Google Sheets workflow that checks record IDs, updates designated columns and routes missing or duplicate matches to review.

A pink pen targets one paper-ledger column while ambiguous ID tags wait in a review tray.

Checked against the cited sources on .

Prepare your n8n Google Sheets integration

This n8n Google Sheets tutorial proposes a controlled practice workflow: accept one update request, count exact ID matches, update automation_status only for a unique match, and append exceptions to a separate review sheet. The steps and code are a tutorial design, with acceptance criteria below; no firsthand execution results are supplied.

Start with an n8n workspace, an existing working Google Sheets credential and a copied practice spreadsheet. Credential creation, production scheduling, batch processing, scaling and quota optimization are outside scope. Prepare the following fixtures before building. The example Records table supplies suggested practice data: keep the IDs as text. Submit four requests separately, one per execution, using record_id values A-001, A-002, A-999 and an empty string, each with automation_status set to ready. Leave A-999 absent from Records.

Suggested practice-sheet design
LocationFieldsPurpose
Records sheetrecord_id, automation_status, team_notesOperational practice data
Review sheetrequested_id, proposed_value, classification, match_countException review
Requestrecord_id, automation_statusOne proposed update
Example Records table: suggested practice data
record_idautomation_statusteam_notes
A-001pendingConfirm delivery address
A-002pendingWaiting for finance
A-002on_holdCall before dispatch

We think column ownership is worth deciding before connecting a write node: it makes the intended change easier for a teammate to review.

1. Prepare one request and read the rows

A request slip, ledger and empty envelope represent the n8n Google Sheets read step and its empty-result path.
One request and a small practice sheet keep the read stage manageable.

Use stable text identifiers in record_id. This exercise uses exact text equality: no trimming, case conversion or numeric conversion. For example, A-001 differs from a-001. Reading every row keeps this small practice exercise straightforward. Build the first nodes as follows.

  1. Add Manual Trigger, then Edit Fields named Request.
  2. In Request, set record_id to A-001 and automation_status to ready. Keep one request per execution.
  3. Add the Google Sheets node with Get Row(s). Select the existing credential, document and Records sheet; leave read filters unset.
  4. In the read node's Settings, enable Always Output Data.

n8n documents existing credential selection and default all-row retrieval for Get Row(s). Always Output Data emits an empty item when a node returns no data; the matching code must exclude that placeholder.

Sources: n8n-docs/docs/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets/sheet-operations.md at main · n8n-io/n8n-docs · GitHub, n8n-docs/docs/build/understand-workflows/workflow-components/work-with-nodes.md at main · n8n-io/n8n-docs · GitHub, n8n-docs/docs/integrations/builtin/core-nodes/n8n-nodes-base.set.md at main · n8n-io/n8n-docs · GitHub

2. Count matches and route the request

Matching gates divide the request into a unique-update path and an exception-review path.
The suggested routing separates unique matches from requests needing review.

Add a Code node after the read and select JavaScript, Run Once for All Items. n8n supports accessing all input items and referencing a named node's first item. Enter this proposed tutorial code:

const request = $('Request').first().json; const id = request.record_id; const valid = typeof id === 'string' && id.trim().length > 0; const rows = $input.all().map(item => item.json).filter(row => Object.prototype.hasOwnProperty.call(row, 'record_id')); const count = valid ? rows.filter(row => typeof row.record_id === 'string' && row.record_id === id).length : 0; return [{ json: { requested_id: id ?? '', proposed_value: request.automation_status, classification: !valid ? 'invalid' : count === 1 ? 'unique' : count === 0 ? 'missing' : 'duplicate', match_count: count } }];

Add a Switch node with rules for classification equal to unique, missing, duplicate and invalid. Enable its Extra Output fallback. These classifications are editorial conventions. Connect unique toward the update branch; connect the other outputs and fallback toward review.

Suggested update and review flow: 1. Read; 2. Classify; 3. Route; 4. Verify

In our view, an unexpected classification belongs in review rather than on a write path. That makes the fallback a deliberate decision.

Sources: Using the Code node, n8n-docs/docs/build/work-with-data/transform-data/expression-reference/nodeinputdata.md at main · n8n-io/n8n-docs · GitHub, n8n-docs/docs/build/work-with-data/reference-data/reference-previous-nodes.md at main · n8n-io/n8n-docs · GitHub, n8n-docs/docs/integrations/builtin/core-nodes/n8n-nodes-base.switch.md at main · n8n-io/n8n-docs · GitHub

3. Restrict the write and append exceptions

A broad roller and a fine pen contrast unrestricted writing with designated-column updates.
Explicit mappings express which columns the automation is intended to change.

On the unique branch, configure the n8n Google Sheets node using the steps below. Update Row updates existing rows, and manual mapping specifies individual columns. Edit Fields can discard fields that were not explicitly set.

  1. Add Edit Fields to the unique branch. Set record_id from requested_id and automation_status from proposed_value.
  2. Enable the option that discards other input fields.
  3. Add Google Sheets Update Row for the Records sheet and select record_id as the matching column.
  4. Choose Map Each Column Manually. Map record_id and automation_status only; do not use Append or Update Row.

Omit team_notes entirely; remove its mapping instead of leaving it blank. Supplied master-branch implementation evidence shows that manual mapping for Google Sheets node versions 4 and later converts mapped null or undefined values to empty strings. Another helper skips null or undefined properties it receives, so upstream mapping matters. The documentation is undated and the implementation is unpinned; installed releases and interface labels may differ.

For the review branch, use Google Sheets Append Row on the Review sheet. Manually map requested_id, proposed_value, classification and match_count from classification output. Append Row adds a row at the end; this review procedure is our suggested design, not a built-in exception-review feature.

Sources: n8n-docs/docs/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets/sheet-operations.md at main · n8n-io/n8n-docs · GitHub, n8n-docs/docs/integrations/builtin/core-nodes/n8n-nodes-base.set.md at main · n8n-io/n8n-docs · GitHub, n8n/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheet.ts at master · n8n-io/n8n · GitHub, n8n/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts at master · n8n-io/n8n · GitHub

4. Verify changes and troubleshoot

Paired ledger strips and four fixture trays support checking updates and preserved team notes.
Compare before-and-after contents across the suggested acceptance cases.

Record team_notes before each run, execute the workflow, then re-read the sheet. Use these suggested acceptance criteria for your n8n Google Sheets workflow.

Suggested acceptance criteria, not observed results
RequestRecords sheetReview sheet
Unique IDOnly automation_status changes; team_notes preservedNo entry
Missing IDUnchangedMissing entry, count 0
Duplicated IDBoth matching rows unchangedDuplicate entry, matching count
Blank IDUnchangedInvalid entry, count 0

For unexpected results, inspect Executions and use Execute step to inspect individual nodes. Check the selected document, sheet, header and data locations, ID types, classification output and write mappings. If replacing the all-row read with a filtered read, explicitly select Return All Matches: otherwise n8n documents returning only the first matching result.

Column ownership reduces the write surface, but the supplied sources establish no transactional uniqueness, locking or conflict detection between lookup and update. Concurrent edits to automation-owned cells can therefore fall outside this practice workflow's protection.

Sources: Sheet Within Document operations | Nodes | n8n Docs, n8n-docs/docs/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets/sheet-operations.md at main · n8n-io/n8n-docs · GitHub, n8n-docs/docs/build/understand-workflows/workflow-components/work-with-nodes.md at main · n8n-io/n8n-docs · GitHub, n8n-docs/docs/build/flow-logic/handle-errors-gracefully.md at main · n8n-io/n8n-docs · GitHub

Put this into practice

Hands-on n8n challenges

Pick a challenge and build a working workflow in your own n8n environment, with five progressive tips per challenge.

Try a hands-on challenge

For your team

Custom n8n training programs for one team or department, run on your own n8n instance with your own tools and data.

Training for your team

n8n skills assessment

A free quiz of about 20 minutes: 30 questions in 10 skill areas and a level from Beginner to Expert. On AI Adoption Score, another project by the author of this site.

Get your n8n level