Webhook to save deleted records
Save record prior to deletion
Objective: In this example our primary goal is to track each record that was deleted from our table inside a Google Sheet.Â
Start by creating a new Sheet and open the script editor
In the script editor paste the following code in but replace each instance of the parameter with the name of your data. Â
function doPost(e) {
//Let's get the active sheet
var sheet = SpreadsheetApp.getActiveSheet();
//Save each value as variable.
var id = e.parameter['id'];
var name = e.parameter['field_36'];
var email = e.parameter['field_40'];
var phone = e.parameter['field_42'];
var value = e.parameter['field_44'];
var date = e.parameter['field_45'];
//Add values into a new row
sheet.appendRow([
"Record Deleted",
id,
name,
email,
phone,
value,
date
]);
}
should look like this:Â
Â
Make sure to select "New" each time you make a change in your code and publish
Â
Â
Copy the address from this URL and paste it as the address for the webhook in your app.Â
When a record is deleted you should now see that record in the spreadsheet.Â
Â