How to identify if a record has been deleted?

Topic Labels: Automations
2448 4
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

I’m writing a script that where I need to identify if a record has been deleted or not based on the recordId. From what I can tell a deleted record doesn’t return any values identifying its active state in the record object when using the selectRecordAsync() function.

Is there a work around for this?

4 Replies 4

@Arron_Kochanowicz - It sounds like you have the record ID and want to check against a table of records, yes?

I’ve had a similar situation with the same records in 2 tables. When a record was deleted from table 1 I wanted to mark the same record in table 2 as cancelled.

I wrote a script automation that did this:

  • Get a list of all IDs in table 1
  • Get a list of all IDs in table 2
  • Loop through the records in table 2 and check if each one is still in the list from table 1
  • If not, can assume it is deleted, so mark as cancelled

For others searching for this who are looking for a non-scripting way of doing this, there is an undocumented hack that can accomplish this by using Airtable Sync.

I gained this knowledge from @Justin_Barrett, who was the first person that I know of to discuss this hack:

  1. Take the view of source records that you want to monitor for deletion, and sync them to a destination sync table.

  2. In the destination sync table, select the option to keep deleted records after they are deleted from the source table.

  3. Airtable only gives us ONE HIDDEN WAY to tell if a record has been deleted from the source, which is to create a button field that opens the source record. This button will appear visibly active when the source record exists, and this button will visibly dim to let you know when the source record has been deleted.

  4. However, we can also create a formula field that is equal to the button field. This formula results in the URL of the source record when the button is active, but the formula results in nothing when the button is dimmed.

So this formula is what you would use to determine whether the source record still exists or has been deleted.

However, it is very important to note that Airtable Sync does not automatically synchronize data on a reliable schedule, which could be a key stumbling block here.

Airtable states that Airtable Sync updates approximately every 5 minutes, but this is not true. The sync actually happens at some random point between 5 minutes and 20 minutes. But even worse, it will ONLY sync if there has been recent activity within the destination table, not the source table.

So this methodology will be unreliable if you’re looking for changes to be instantly reflected in the destination table, and it will also be unreliable if a record is created then deleted very quickly thereafter. In the latter case, you’ll likely miss knowing about that record altogether.

Thanks, Jonathan.

Yes, your example is very similar to my goals and the same logic should apply. Your suggestion was what I would also expect my script to evaluate. However, I haven’t found a way differentiate between the two tables because the ID of the deleted record is still returned using the selectRecordsAsync() method.

I’m no stranger to JavaScript, but I’m very new to Airtable.

Did you perhaps use an alternative object method from selectRecordsAsync()?

thanks @ScottWorld. This might be a good workaround if I cannot get the scripting working.