Delete Mutiple rows via webhook and API

FatLou
New Member

I have Table A and Table B. Table B holds a reference Column to table A. When I delete a row in Table A I want to create an Action that then deletes all rows in Table B that referenced the deleted row in Table A.

below is how I filled out the workflow

Target Data: Table A
When this happens: Deletes_Only

If this is True:

Reaction: Webhook
Name: Action 1
Preset: Custom
URL: https://api.appsheet.com/api/v2/apps/*******/tables/Table B/Action

HTTP verb: Delete
HTTP Content: JSON

Body Template:

The goal here is to SELECT all of the rows from Table B where the value of the [Properties] column is equal to the value of ID from the row deleted in Table A.
{
โ€œActionโ€: โ€œDeleteโ€,
โ€œPropertiesโ€: {
โ€œLocaleโ€: โ€œen-USโ€,
โ€œLocationโ€: โ€œ47.623098, -122.330184โ€,
โ€œTimezoneโ€: โ€œPacific Standard Timeโ€
},
โ€œRowsโ€: [
<<Start: Select(Table B[ID], [Properties] = [_THISROW].[ID])>>

{
  "ID": "<<[ID]>>"
}

<>
]
}

Below is the result in the Audit history. It seems to be returning the correct IDs but it is not deleting them from the table.

Row:
[
โ€œ19โ€,
โ€œ12vlwZirโ€,
โ€œWill Testโ€,
โ€œWills Testโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œEr93uGK5โ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œZIUnmByV , 7MGTEfIY , QV1Bg624โ€,
โ€œโ€
]
Properties:
{
โ€œTableNameโ€: โ€œPropertiesโ€,
โ€œtzOffsetโ€: โ€œ240โ€,
โ€œsettingsโ€: โ€œ{โ€_RowNumber":โ€œ0โ€,"_EMAIL":"","_NAME":"","_LOCATION":"",โ€œOptions Headingโ€:"",โ€œOption 1โ€:"",โ€œOption 2โ€:"",โ€œCountry Optionโ€:"",โ€œLanguage Optionโ€:"",โ€œOption 5โ€:"",โ€œOption 6โ€:"",โ€œOption 7โ€:"",โ€œOption 8โ€:"",โ€œOption 9โ€:"","_THISUSER":โ€œonlyvalueโ€}",
โ€œapiLevelโ€: โ€œ1โ€,
โ€œisPreviewโ€: โ€œundefinedโ€,
โ€œcheckCacheโ€: โ€œfalseโ€,
โ€œlocaleโ€: โ€œen-USโ€,
โ€œlocationโ€: โ€œnullโ€,
โ€œappTemplateVersionโ€: โ€œ1.000755โ€,
โ€œlocalVersionโ€: โ€œโ€,
โ€œtimestampโ€: โ€œโ€,
โ€œrequestStartTimeโ€: โ€œ2019-07-16T23:36:36.153Zโ€,
โ€œlastSyncTimeโ€: โ€œโ€,
โ€œappStartTimeโ€: โ€œโ€,
โ€œdataStampโ€: โ€œโ€,
โ€œclientIdโ€: โ€œc5da2c8d-4e37-4bb8-b5e8-db46567c8949โ€,
โ€œbuildโ€: โ€œundefinedโ€,
โ€œrequestIdโ€: โ€œ95293962โ€,
โ€œRowSizeโ€: 67,
โ€œAppTemplateNameโ€: โ€œ******โ€,
โ€œOperationโ€: โ€œDelete rowโ€,
โ€œRecordTypeโ€: โ€œStartโ€
}

ร—
Audit Log Details
Row:
[
โ€œ19โ€,
โ€œ12vlwZirโ€,
โ€œWill Testโ€,
โ€œWills Testโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œEr93uGK5โ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œโ€,
โ€œZIUnmByV , 7MGTEfIY , QV1Bg624โ€,
โ€œโ€
]
Properties:
{
โ€œTableNameโ€: โ€œPropertiesโ€,
โ€œtzOffsetโ€: โ€œ240โ€,
โ€œsettingsโ€: โ€œ{โ€_RowNumber":โ€œ0โ€,"_EMAIL":"","_NAME":"","_LOCATION":"",โ€œOptions Headingโ€:"",โ€œOption 1โ€:"",โ€œOption 2โ€:"",โ€œCountry Optionโ€:"",โ€œLanguage Optionโ€:"",โ€œOption 5โ€:"",โ€œOption 6โ€:"",โ€œOption 7โ€:"",โ€œOption 8โ€:"",โ€œOption 9โ€:"","_THISUSER":โ€œonlyvalueโ€}",
โ€œapiLevelโ€: โ€œ1โ€,
โ€œisPreviewโ€: โ€œundefinedโ€,
โ€œcheckCacheโ€: โ€œfalseโ€,
โ€œlocaleโ€: โ€œen-USโ€,
โ€œlocationโ€: โ€œnullโ€,
โ€œappTemplateVersionโ€: โ€œ1.000755โ€,
โ€œlocalVersionโ€: โ€œโ€,
โ€œtimestampโ€: โ€œโ€,
โ€œrequestStartTimeโ€: โ€œ2019-07-16T23:36:36.153Zโ€,
โ€œlastSyncTimeโ€: โ€œโ€,
โ€œappStartTimeโ€: โ€œโ€,
โ€œdataStampโ€: โ€œโ€,
โ€œclientIdโ€: โ€œc5da2c8d-4e37-4bb8-b5e8-db46567c8949โ€,
โ€œbuildโ€: โ€œundefinedโ€,
โ€œrequestIdโ€: โ€œ95293962โ€,
โ€œRowSizeโ€: 67,
โ€œAppTemplateNameโ€: โ€œ77009382-fb60-4c59-b103-5a2a5c9b8849โ€,
โ€œOperationโ€: โ€œDelete rowโ€,
โ€œRecordTypeโ€: โ€œStartโ€
}

0 8 1,402
8 REPLIES 8

Based on the information you included from the Audit History, it appears that you are reporting a problem with the application โ€œRI_phase1-742623โ€. Can you confirm that?

I looked at rule โ€œDeletePropertyPipelineOrphansโ€ on the theory that this was the webhook rule that was failing. The JSON template looks correct.

When I searched the Audit History, I could not find any instance in which that rule had been invoked in the past 5 days.

I can investigate further if you provide:

  1. Your account id
  2. The app name
  3. The workflow rule name
  4. The timestamp from the Audit History where the workflow rule was invoked.

Are you aware that if you set the โ€œIs part ofโ€ property on Reference in table B, AppSheet will automatically delete the child records in table B when the parent record in table A is deleted? That would be easier than deleting the children using a webhook that calls the REST API.

FatLou
New Member

That seems to work and it is a lot easier. I did not realize that was a function. Thanks.

FatLou
New Member

One more issue is that when rows are deleted from sheets it clears the rows it does not however delete the actual rows.

That is intentional because some customers use row number as a key (even thought doing that is strongly discouraged). If we deleted the actual row, the row numbers of the following rows would change and cause the โ€œrow number keysโ€ to change.

Ok,

From a CS perspective perhaps you guys should force an ID column. That is much better practice and in my specific case I have very โ€œactive/ busyโ€ tables so deletions leave massive row gaps which is not a problem programmatically but the tables start to look strange.

Either way, keep up the good work.

-Will

Hi Will,

Point well taken.

I forgot to mention that you can manually โ€œgarbage collectโ€ the empty rows provided you do that while the app is idle. Since you are not using row number as a key it is safe to simple delete the empty rowsโ€ฆ

Hi, could you elaborate on how to do so ?

If you are not using the row number as a key you can manually โ€œgarbage collectโ€ the empty rows by simply deleting the empty rows from the worksheet. You must only do this while the app is idle.

Simple open the worksheet in Google Sheets or Excel and delete all of the empty rows. In Excel you must then save the updated worksheet.

Once you have done this, your application users should perform a sync to retrieve the updated worksheet contents.

Top Labels in this Space