Delete a record from Google sheet

Hi, I am trying to create a delete function which will delete a selected record. I have had a look at muneer’s suggestion at this link: Profile - muneer - Community and I am not sure if it pertains to my required ‘single row delete’ requirements or to a ‘delete all records’. I suspect the former to be the solution.

I have my app variable data set up as below:

Using a record called “TESTDELETE” for my example I shall try to explain what I have achieved so far (see below):

I wish to delete the “TESTDELETE” from my Source Data Google Sheet “FVENTRYFORM

When the user clicks the “Delete” button the first of two error messages (FVYesNoLabel) appears to warn the user of their actions (see below)

The user then has the option to proceed or not by clicking either the, now displayed, “Delete” or “Cancel” button. If, at this point, the user decides to click the “Delete” button they are faced with a final message in the form of the alert (FVDeleteAlert1) shown below:

When “Confirm” is clicked, the “TEST DELETE” record in question should then be deleted from the Source Data Google Sheet “FVENTRYFORM”.

Looking at my blocks below and then looking at muneer’s solution, I am wondering how to implement it into my project.

My blocks:

The problem I am having is in the “When/BtnFVDelYes/click” block after I call the “FVDeleteAlert” alert msg. Because this is first time I have tried to use the “wasConfirmed” blocks I am not sure how to make them delete the “TESTDELETE” record and briefly display a “Record Deleted” msg.

This was when I found muneer’s solution ( image below) which suggested to me that my approach must be wrong but I am not sure how to incorporate his solution into my blocks.

In the “for row id” socket would I use my "row_data" or “row_number” variable or something else completely?

Do I put muneer’s blocks in my “When/BtnFVDelYes/click” blocks, and if so, where?

I am very confused and suffering with “block blindness”.

Andos.

1 Like

I have to say that I changes the subject of the post to something more meaningful than my own name.

In your FVDeleteAlert you are having two IF Conditions that refer to the same thing. You should use ELSE in the first condition to manage the second condition.

image
Can you explain what the app variable row_data contains. For the delete row block to work you need to supply the row ID which is either a number of the order of this row in the sheet or a unique string to identify this record. It seems that this variable contains the row information which is not what is expected by the delete row block.

2 Likes

Hi @muneer, the “app variable row_data” contains the record’s field data (see image below)

Would the “app variable row_number” be the row_id as in the image below?

Screenshot 2022-02-17 21.07.17

Also, below I have amended my “FVDeleteAlert”. Is this now correct?

Andos.

1 Like

Yes, that would be a good choice.

I believe you are placing them the wrong way round.

Ok, thanks @muneer, I shall change that and let you know how I get on.

Thanks,

Andos.

1 Like

Hi @muneer, that did the trick. Thanks!

However, I have noticed that once a record has been deleted it leaves an empty row in the Data Source Google Sheet. This then causes the row data of subsequent records to not display in the app when a search record is located below the empty row in the Source Data Google Sheet.

Is there a way for the app to also remove the deleted row’s id and consequently the empty row in the Google Sheet?

Andos.

1 Like

This should not be the case. When a record is deleted then the rows below it jumps up.

Can you please check again and if this behavior persists then you need to report a BUG.

@jared can you have a look?

I tried this is a few times so I shall have to report a bug. Do I report this to Google?

Andos.

1 Like

No, you should report it to Thunkable here:

Make sure to provide a link to a basic project that demonstrates this problem.

1 Like

Hey guys! @muneer @andos-avlog @tatiang

Thanks for the triaging here. I’m seeing the same thing on my end.

I’m filing a bug report at the moment!

2 Likes

Ok @taiang, I shall do that tomorrow.

Andos.

2 Likes

Sounds like @jared was able to duplicate the issue so it’s probably not necessary at this point. Hopefully this gets fixed soon!

1 Like

Hi @tatiang, I hope so too!

Many thanks @tatiang, @muneer, @jared,

Andos.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.