Google Sheets · Arazzo Workflow

Google Sheets Overwrite or Append Rows

Version 1.0.0

Inspect a range and branch — overwrite it in place when it already has data, otherwise append fresh rows.

1 workflow 1 source API 1 provider
View Spec View on GitHub Google WorkspaceProductivitySpreadsheetsArazzoWorkflows

Provider

google-sheets

Workflows

overwrite-or-append-rows
Overwrite a range in place when populated, otherwise append the rows.
Reads a range and either overwrites it with the supplied rows when it already holds data, or appends those rows when the range is empty.
3 steps inputs: accessToken, range, spreadsheetId, values outputs: appendedRange, existingValues, overwrittenRange
1
inspectRange
getValues
Read the target range and branch on whether it already contains data.
2
overwrite
updateValues
Overwrite the populated range in place with the supplied rows.
3
appendRows
appendValues
Append the supplied rows to the empty range so they land at the start of the table.

Source API Descriptions

Arazzo Workflow Specification

google-sheets-overwrite-or-append-rows-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Google Sheets Overwrite or Append Rows
  summary: Inspect a range and branch — overwrite it in place when it already has data, otherwise append fresh rows.
  description: >-
    A write strategy that adapts to the current state of a range. The workflow
    reads the target range and branches: when the range already contains data
    it overwrites that range in place with the supplied rows, and when the range
    is empty it appends the rows so they land at the start of the table. Every
    step spells out its request inline so the flow can be read and executed
    without opening the underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: googleSheetsApi
  url: ../openapi/google-sheets-openapi.yml
  type: openapi
workflows:
- workflowId: overwrite-or-append-rows
  summary: Overwrite a range in place when populated, otherwise append the rows.
  description: >-
    Reads a range and either overwrites it with the supplied rows when it
    already holds data, or appends those rows when the range is empty.
  inputs:
    type: object
    required:
    - accessToken
    - spreadsheetId
    - range
    - values
    properties:
      accessToken:
        type: string
        description: OAuth 2.0 bearer access token with the spreadsheets scope.
      spreadsheetId:
        type: string
        description: The ID of the spreadsheet to write to.
      range:
        type: string
        description: The A1 notation range to inspect and write (e.g. Sheet1!A1:C10).
      values:
        type: array
        description: A two-dimensional array of cell values to write.
        items:
          type: array
          items: {}
  steps:
  - stepId: inspectRange
    description: Read the target range and branch on whether it already contains data.
    operationId: getValues
    parameters:
    - name: Authorization
      in: header
      value: Bearer $inputs.accessToken
    - name: spreadsheetId
      in: path
      value: $inputs.spreadsheetId
    - name: range
      in: path
      value: $inputs.range
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      existingValues: $response.body#/values
    onSuccess:
    - name: hasData
      type: goto
      stepId: overwrite
      criteria:
      - context: $response.body
        condition: $.values.length > 0
        type: jsonpath
    - name: noData
      type: goto
      stepId: appendRows
      criteria:
      - context: $response.body
        condition: $.values.length == 0
        type: jsonpath
  - stepId: overwrite
    description: Overwrite the populated range in place with the supplied rows.
    operationId: updateValues
    parameters:
    - name: Authorization
      in: header
      value: Bearer $inputs.accessToken
    - name: spreadsheetId
      in: path
      value: $inputs.spreadsheetId
    - name: range
      in: path
      value: $inputs.range
    - name: valueInputOption
      in: query
      value: USER_ENTERED
    requestBody:
      contentType: application/json
      payload:
        range: $inputs.range
        majorDimension: ROWS
        values: $inputs.values
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      updatedRange: $response.body#/updatedRange
      updatedCells: $response.body#/updatedCells
    onSuccess:
    - name: done
      type: end
  - stepId: appendRows
    description: Append the supplied rows to the empty range so they land at the start of the table.
    operationId: appendValues
    parameters:
    - name: Authorization
      in: header
      value: Bearer $inputs.accessToken
    - name: spreadsheetId
      in: path
      value: $inputs.spreadsheetId
    - name: range
      in: path
      value: $inputs.range
    - name: valueInputOption
      in: query
      value: USER_ENTERED
    - name: insertDataOption
      in: query
      value: INSERT_ROWS
    requestBody:
      contentType: application/json
      payload:
        range: $inputs.range
        majorDimension: ROWS
        values: $inputs.values
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      updatedRange: $response.body#/updates/updatedRange
      updatedCells: $response.body#/updates/updatedCells
  outputs:
    existingValues: $steps.inspectRange.outputs.existingValues
    overwrittenRange: $steps.overwrite.outputs.updatedRange
    appendedRange: $steps.appendRows.outputs.updatedRange