How to get 'Deletes_Only' Bot on child record to work when you delete a parent record, and all child records are deleted

I have three tables.

Table 1: Work Orders (Parent)

Table 2: Work Order Line Items (Child)

Table 3: Inventory

I currently have two bots working using webhooks.
Adds_Only - Whenever a work order line item is created, it adds the qty to the inventory table.
Deletes_Only - If that line item is deleted, it removes the qty from the inventory table.

Here is my JSON text, the Deletes_Only is the same except it subtracts from Qty Produced instead of adding.

{
“Action”: “Edit”,
“Properties”: {
“Locale”: “en-US”,
“Timezone”: “Mountain Standard Time”
},

“Rows”: [
<<START:SELECT(Parts[Part ID],[Description]=[_THISROW].[Product/Part])>>
{

“Part ID”: “<<[Part ID]>>”,
“Qty Produced”: “<<[_THISROW].[Qty]+[Qty Produced]>>”

}
<>
]
}

If I delete a Work Order, it deletes all child records in the Work Order Line Items Table, but the ‘Deletes_Only’ bot does not trigger when this happens.

How do I make a bot that triggers off of the Work Orders table that runs for each child record?

Any help would be much appreciated.

Thanks!

Automation for when a record is Deleted can be tough. The reason is, that once the record is deleted, the Bot can’t access any of the data from that record. You should set up your automation flow to do the processes that need done when a record is deleted first, then delete the record.

2 Likes

So I ended up figuring out a work around for this. I removed the standard delete action from Work Orders. Replaced it with a grouped action.

First it runs Data: Execute an action on a set of rows. This deletes all related Work Order Line Items. This triggers my ‘Deletes_Only’ Bot for every row deleted.

Second it deletes the work order itself.

I find it very strange that this method triggers the ‘Deletes_Only’ but when a child record has ‘is part of’ selected and you delete the parent, it does not trigger for the children. Can anyone say if this is intentional or if this is a bug?

2 Likes