<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
How to Delete All Rows in a Google Sheets Spreadsheet using Workflows
Okta Classic Engine
Okta Identity Engine
Workflows

Overview

This article teaches how to delete all rows in a Google Sheets spreadsheet using Workflows.

 

Solution

All the rows need to be deleted in the following spreadsheet except the headers:


Google Sheets spreadsheet.

 

This flow deletes a range of rows from a Google Sheets spreadsheet using the Google Sheets API:


Workflows flow to delete all spreadsheet rows.

 

JSON request indicating the rows to clear:

{
  "requests": [
    {
      "deleteDimension": {
        "range": {
          "sheetId": 0,
          "dimension": "ROWS",
          "startIndex": 1,
          "endIndex": 11
        }
      }
    }
  ]
}

 

Running the flow will clear all the spreadsheet rows:

How the flow works

  1. The Flow Control-Assign card sets the Google Sheets spreadsheet ID.
  2. The Text-Compose card builds the API URL: /v4/spreadsheets/{Spreadsheet ID}:batchUpdate. It uses the Spreadsheet ID from the Assign card.
  3. The second Text-Compose card builds the JSON request body. It uses the deleteDimension request to delete rows 2–11 (startIndex: 1endIndex: 11) from the first sheet (sheetId: 0). Update startIndex and endIndex to match the rows you want to delete.
  4. The Google Sheets-Custom API Action card makes a POST request to the Google Sheets spreadsheets.batchUpdate API.

 


Spreadsheet after running the flow.

 

Related References

 

Loading
How to Delete All Rows in a Google Sheets Spreadsheet using Workflows