I am building a generic workflow for records deleted. I want to pass information to an API (to synchronize data with a SQL database). For Create and Update, it is simple: when the API is called, the record is retrieved and it contains the appname as well.
When a record is deleted, you can not retrieve it. In order to get the appname I tried to restore it with parameters set to silent=true and hook=false. The record is restored and the response contains the appname. But… when I remove it again, with the parameters also set to silent=true and hook=false, the workflow is triggered again and creating a loop now…
I tried to get the appname in a workflow script, but I can’t find how. I can not get the record (the workflow is triggered when the delete is already done and there is no variable available containing the appname.
I do have a workarround now:
The API call will restore the record in order to get the appname
In the workflow I delete the record in the end in silent mode. This does work, but it is not the best option. It would be great if you could retrieve the appname from a deleted item in a script.
Any thoughts?
This is my current solution:
- On delete a workflow is triggered
- The workflow calls on API (on my own server) to tell a record is deleted
- My PHP script restores the deleted item and retrieves the appname (to update the corresponding table in the local database)
- The workflows last step is to delete the record (again) without sending a webhook.
Correction: this also creates a loop. On the last step (when the record is deleted) it will trigger the flow again. No matter what. Silent is set to true, trigger webhook and automation are off, but still the workflow is triggered again creating a loop.