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

In this guide:

Okta Workflows guides

Okta Workflows guides offer questions and answers from the Okta Workflows community office hours. They also come from the #okta-workflows channel on the Mac Admins Slack and other places. Read all the other guides.

How do you delete all rows in a Google Sheets spreadsheet using Okta Workflows?

This guide will teach you how to delete all rows in a Google Sheets spreadsheet using Okta Workflows.

Delete Google Sheets rows

You need to delete all the rows in the following spreadsheet except the headers:

Google Sheets
Google Sheets

Workflows flow

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

Spreadsheet after running the flow.
Workflows flow to delete all 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: 1, endIndex: 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.

JSON request indicating rows to clear:

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

Run the flow

Running the flow will clear all the spreadsheet rows:

Spreadsheet after running the flow.
Spreadsheet after running the flow.

Okta Workflows resources

Leave a Reply

Discover more from Max Katz

Subscribe now to keep reading and get access to the full archive.

Continue reading