Workflow to delete all records in a Table

I’m having trouble getting a Workflow Webhook to delete ALL the records in a table at ounce. It seems to fire just fine, but the table data does not get deleted. I read a bunch of eh guidance but still am struggling with it. Any help would be appreciated.

0 21 3,171
21 REPLIES 21

Steve
Platinum 4
Platinum 4

Please detail what you’ve attempted.

Thanks Steve.

Update to my previous post: It seem to fire sometimes, but not others. (see audit history) In either case it does not delete the data in my table.

I set up an action to trigger this workflow intended to delete all the rows in a table. I am leaving the body empty so it uses the default template.

What is the error?

Properties:
{
“RestAPIVersion”: 2,
“TableName”: “Fish Data Input From App”,
“AppTemplateVersion”: “1.000126”,
“AppTemplateName”: “2af8237d-c0fc-41af-901b-e29126bf49ea”,
“Operation”: “REST API invoke”,
“RecordType”: “Stop”,
“ResultSuccess”: false,
“ResultException”: “System.NullReferenceException: Object reference not set to an instance of an object.\r\n at Nirvana.source.api.PublicAPIV2Controller.RestApi_Action_Internal(Context context, LogOperation logOperation, String appId, String applicationAccessKey, String tableName, String actionName, JObject data) in d:\a\1\s\Nirvana\Controllers\API\PublicAPIV2Controller.cs:line 409”,
“StatusCode”: “InternalServerError”,

Hmmm… Unfortunately, I have virtually no experience with webhooks, and neither the error nor the screenshots provide any information that leads me to any helpful advice. What I can offer is an alternative approach using actions alone:

  1. For the table from which the rows are to be deleted (Fish Data Input from App?), create an action called (e.g.) Delete without confirmation:

    • Do this: Data: delete this row

    • Needs confirmation: OFF

  2. For your trigger table (Workflow Trigger?), create an action called (e.g.) Delete All Fish Data.

    • Do this: Data: execute an action on a set of rows

    • Referenced Table: (table from which the rows are to be deleted (Fish Data Input from App?))

    • Referenced Rows:

      ORDERBY(
        FILTER("Fish Data Input from App", TRUE),
        [_ROWNUMBER],
          TRUE
      )
      

      Replace Fish Data Input from App with the correct name of the table from which the rows are to be deleted.

    • Referenced Action: Delete without confirmation

Use this Delete All Fish Data action instead of your webhook.

Thank you. This works to well to delete the data line by line.

The challenge this approach creates is very long sync times if there is a large amount of data to delete. I created something similar in an earlier version and it took about 45 minutes to delete 2400 rows of data.

I was hoping to select all rows and delete them all once. Perhaps there is Reference Rows expression to select them all.

I don’t think this is a viable solution in the short and medium term if you are going to need to do this a lot (meaning several times a day). IMHO, you are better off writing a script that is triggered by the webhook to delete all the rows.

I’ll defer to the expert.

If you trigger the delete action (from Steve’s suggestion above) using a Change Data action in a workflow - the edit to the table is made in one edit, meaning they get mass deleted at once. The downside to deleting with a workflow is that you have to wait for the workflow to be triggered and for the app to sync afterwards.

But if this is a “set it and forget it thing” then it might be a solution.

Thank you for your help. I’ll continue to investigate how to implement a webhook.

Hi Timothy,

The error “System.NullReferenceException” is indicating that there is a bug in AppSheet.
I suspect that the bug may be triggered by something wonky in your webhook, but you should never see a Null Ref Exception regardless of what your webhook does.

Please submit a bug report and supply the following information:

  1. Your account id
  2. The application name
  3. The table name
  4. The workflow rule or report name
  5. A complete description of the problem
  6. The exact steps to reproduce the problem
  7. Please go to https://www.appsheet.com/account/account#_tab_acctConfig and check the option that enables support access.

Thank you MultiTech_Visions! That is exactly what I was looking for and it works perfectly!

Thank you to all that helped.

I have a similar question. I have a table that I create quotes in deck view. Can I create and action button to delete all quotes?

Yep.

I can create action button to delete one row. How would I delete all the rows? I don’t see an option for that.

Use an action of type Data: Execute an action on a set of rows to identify all rows and invoke a separate action that performs a Data: delete this row action for each row.

I got that far. I guess I don’t know what the expression is to select all the current rows. Obviously I don’t want to delete the header row in the table.

FILTER("table-name", TRUE) will produce a list of all rows in the table named table-name.

Don’t worry about the header row–it’s not considered a data row and will never be impacted by an action.

Thanks for sharing, this helped me even after a couple of years.

Thanks

It worked! Thanks again.

Use AppScript to write make a delete all function & trigger via AppSheet.

 
AppScript Code here:
function deleteRowsFromRowTwo() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var numRows = sheet.getLastRow() - 1// get the number of rows starting from row 2
  sheet.deleteRows(2numRows); // delete the rows starting from row 2
}

 

Top Labels in this Space