# Delete Row for "Create new action..." workflows

**URL:** https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390
**Category:** Ask for Help
**Tags:** actions
**Created:** [January 19, 2021, 2:17am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390 "2021-01-19T02:17:23Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ray\_d](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@ray\_d](https://community.glideapps.com/u/ray_d)
#### Post date: [January 19, 2021, 2:17am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/1 "2021-01-19T02:17:23Z")

</div>

I’m surprised there’s an Add Row, but no Delete Row for the custom action builder.

Use Case:  
I’m trying to make a one-tap follow / unfollow user function for a social network type of app, but it only works for one-tap follow. If you add Delete Row as an option, we’d be able to do one tap unfollow, enabling slick social network experiences

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/b/4b2ea1aa7ddb4e7dba6150a9e19e0b6a7d4b7602.png)

---

<div class="post-metadata">

### Author: ![wjcv06](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/wjcv06/32/12747_2.png) [@wjcv06](https://community.glideapps.com/u/wjcv06)
#### Post date: [January 19, 2021, 2:25am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/2 "2021-01-19T02:25:00Z")

</div>

You can clear all columns, then with a script remove all the rows with no data

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 19, 2021, 2:25am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/3 "2021-01-19T02:25:49Z")

</div>

The way I normally handle deletions is as follows:

- I have a column in my table called “Is Deleted?” (for simplicity, I just use a number column)
- I present a “Delete” button to the users
- When a user taps on delete, I increment the value of “Is Deleted?” by 1
- I then use a visibility condition to immediately remove the item from view

In some cases, I’ll have a trigger function running in the background that removes any “Is Deleted?” rows from the GSheet.  
In other cases, I’ll actually leave the row intact and include a “Deleted At” timestamp and “Deleted By” email address/user ID to identify the user that deleted the item, and when. Both of these get set in the same custom action as the “Is Deleted?” increment.

---

<div class="post-metadata">

### Author: ![ray\_d](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@ray\_d](https://community.glideapps.com/u/ray_d)
#### Post date: [January 19, 2021, 2:43am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/4 "2021-01-19T02:43:33Z")

</div>

@wjcv06 @Darren_Murphy what scripts do you use to automate deletion and how long do they take to kick in? Can you/do you have them running continuously eg. every second or every 5 seconds?

---

<div class="post-metadata">

### Author: ![Jonathon\_Kohn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jonathon_kohn/32/8593_2.png) [@Jonathon\_Kohn](https://community.glideapps.com/u/Jonathon_Kohn)
#### Post date: [January 19, 2021, 2:51am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/5 "2021-01-19T02:51:39Z")

</div>

The problem isn’t creating a hack to “delete” a row. It’s to actually delete a row and keep our sheets clean. I have an app with over 30,000 rows and all the data is sitting at the bottom because this feature doesn’t exist.

I’m sure it will come soon but no idea what the reasoning behind it is.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 19, 2021, 2:52am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/6 "2021-01-19T02:52:42Z")

</div>

It depends on the use case.  
If I need the row removed ASAP, then I’ll use an On Change trigger.  
If I don’t, then I’ll use a time based trigger and set it to run periodically to clean things up.

Here’s an example of a generic script that I use:

```
function remove_deleted_rows(sheet) {
  var rows = sheet.getLastRow();
  for (var row=rows; row>=2; row--) {
    var deleted = sheet.getRange(row,2).getValue();
    if (deleted) {
      sheet.deleteRow(row);
    }
  }
}

```

One important point is that I _ALWAYS_ use column 2 (B) for my `Is Deleted?` flag (Column A is reserved for RowID). This gives me the confidence to know I can safely use that same function to delete rows in any sheet, and not have to worry about accidentally deleting an entire sheet. I learned this lesson the hard way 😱

---

<div class="post-metadata">

### Author: ![ray\_d](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@ray\_d](https://community.glideapps.com/u/ray_d)
#### Post date: [January 19, 2021, 3:23am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/7 "2021-01-19T03:23:18Z")

</div>

Agreed. Definitely not a good user experience nor a good development practice to try and hack deleting a row. Seems so fundamental. I’m sure they’re working on it, but need to find a way around this for now.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 19, 2021, 3:47am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/8 "2021-01-19T03:47:19Z")

</div>

@ray_d another thing I should point out about the script I posted above (which may not be immediately obvious) is that when processing a sheet, it starts from the bottom and works its way up. This is absolutely _vital_. If you start from the top and work down, then you run the risk of deleting the _wrong_ rows. This is because as soon as you delete a row, the indexes of all the following rows will change, and so you have an immediate off by one error.

Working from the bottom up avoids this problem. When you delete a row, the row indexes below will still change. But because those rows have already been processed, it doesn’t matter.

In terms of timing, although using an On Change trigger is relatively fast, it will still take up to a minute or two before the change is reflected in the app.

This is why I use the ‘Is Deleted?’ flag + visibility approach. It allows you to give the impression that the deletion is instant, even though the row is still there.

---

<div class="post-metadata">

### Author: ![Mauronic](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mauronic/32/21726_2.png) [@Mauronic](https://community.glideapps.com/u/Mauronic)
#### Post date: [January 19, 2021, 4:00am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/9 "2021-01-19T04:00:32Z")

</div>

@Darren_Murphy Do you use integromat? I am asking because some scenarios break with “error 400” when rows are deleted. This is preventing me from doing a delete row in integromat.

---

<div class="post-metadata">

### Author: ![ray\_d](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@ray\_d](https://community.glideapps.com/u/ray_d)
#### Post date: [January 19, 2021, 4:05am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/10 "2021-01-19T04:05:12Z")

</div>

> [@Mauronic](#):
>
> integromat

Are you able to delete a single target row with integromat without error?

---

<div class="post-metadata">

### Author: ![ray\_d](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@ray\_d](https://community.glideapps.com/u/ray_d)
#### Post date: [January 19, 2021, 4:07am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/11 "2021-01-19T04:07:35Z")

</div>

> [@Darren\_Murphy](#):
>
> as you delete a row, the indexes of all the following rows will change, and so you have an immediate off by one error.

If I’m using Row ID as the unique row identifier, wouldn’t that avoid the index change?

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [January 19, 2021, 4:22am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/12 "2021-01-19T04:22:28Z")

</div>

For Sheets, this has to do with the fact that the Sheet API only allows clearing, not deleting but as I have discussed with @Jonathan\_Kohn in another thread, they should have this for Glide Tables.

---

<div class="post-metadata">

### Author: ![ehdubya](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ehdubya/32/24087_2.png) [@ehdubya](https://community.glideapps.com/u/ehdubya)
#### Post date: [January 19, 2021, 4:32am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/13 "2021-01-19T04:32:36Z")

</div>

This is a really cool approach! I’ll definitely heed this advice too!

---

<div class="post-metadata">

### Author: ![ehdubya](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ehdubya/32/24087_2.png) [@ehdubya](https://community.glideapps.com/u/ehdubya)
#### Post date: [January 19, 2021, 4:32am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/14 "2021-01-19T04:32:51Z")

</div>

Same here!

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 19, 2021, 4:42am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/15 "2021-01-19T04:42:31Z")

</div>

> [@ray\_d](#):
>
> If I’m using Row ID as the unique row identifier, wouldn’t that avoid the index change?

You mean the RowID that Glide assigns?  
No, that’s just a string of characters and has no special meaning from the GSheet perspective.

---

<div class="post-metadata">

### Author: ![Mauronic](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mauronic/32/21726_2.png) [@Mauronic](https://community.glideapps.com/u/Mauronic)
#### Post date: [January 19, 2021, 4:46am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/16 "2021-01-19T04:46:17Z")

</div>

I had issues with sheets that use array formulas (most all my sheets).

The error was:

`Invalid requests[0].deleteRange: You cannot insert or delete cells over an array formula.`

Integromat support provided that to me, I am not 100% sure if that’s from their platform or google’s API

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 19, 2021, 5:00am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/17 "2021-01-19T05:00:17Z")

</div>

I’ve done a little with Integromat, but never tried using it to delete spreadsheet rows (as I already have a script solution). I keep telling myself that I need to learn more about Integromat, as I’m sure once I do I can probably save myself a whole heap of coding…

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 19, 2021, 5:04am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/18 "2021-01-19T05:04:54Z")

</div>

> [@Mauronic](#):
>
> Invalid requests[0].deleteRange: You cannot insert or delete cells over an array formula.

My guess would be that error comes from Integromat, as I’ve never encountered it using Apps Script to delete rows. In fact, I just did a quick test using the same script I posted earlier, processing a sheet that contains several arrayformulas, and it executed without error.

---

<div class="post-metadata">

### Author: ![Jacktools\_Net](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jacktools_net/32/18500_2.png) [@Jacktools\_Net](https://community.glideapps.com/u/Jacktools_Net)
#### Post date: [January 19, 2021, 6:50am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/19 "2021-01-19T06:50:47Z")

</div>

You can do this with integromat with two steps. Search one row then delete this row by the row number then repeat.  
You have to do this one by one because the row number changes for all rows behind the deleted one so you have to search again to get the next valid row number.  
So with a web hook you could create a smoth and dangerous solution. What happens when two users delete at the same time…

But not if you use a glide table.  
+1 for the delete action.

---

<div class="post-metadata">

### Author: ![SantiagoPerez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/santiagoperez/32/16807_2.png) [@SantiagoPerez](https://community.glideapps.com/u/SantiagoPerez)
#### Post date: [January 19, 2021, 10:25am UTC](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390/20 "2021-01-19T10:25:33Z")

</div>

Hola @ray_d,

I guess you are a script person but for those of us who are still learning how to use them, there is an alternative which is have Integromat delete it for you.

Yes, Integromat has a “delete row” action that could do this as well.

I hope this is helpful for someone.

[Next page](https://community.glideapps.com/t/delete-row-for-create-new-action-workflows/21390.md?page=2)
