Formula to filter for broken lookup references OR ability to auto-delete subtable rows when a main row is deleted

I have multiple docs that function as “apps” for my team. Workflows often include subtables (click a button in this row, a row is created in a subtable somewhere else).

Inevitably, some of the “master” rows in the main table will get deleted , usually because someone made an error, no longer needs the record, or wants to start over from scratch. But when that happens, all of the subtable rows do NOT get deleted — they get abandoned and live on forever with broken lookup references to the main table, taking up valuable doc space and causing general clutter.

I’d like some combination of this:

  1. A way to filter for rows with broken lookup references. If I could filter for them, I could set up an automation to periodically find and delete those “abandoned” rows.

  2. The ability to configure a lookup column so that if the associated lookup row is deleted, the associated row in the current table will also be deleted. Sometimes I’d want this to happen immediately. Other times, I might want there to be a delay to allow the user some time to backtrack and review the subtable rows that will soon be removed.

This might be an edge case, but this functionality would really improve my team’s workflow.

Hi Tyler,

There’s a handy formula IsFromTable for your case.

Below is a way to set up a filter to hide and button to delete rows with dead references.

For number 2, you can create a button on the main table that uses RunActions to delete the row it’s on and then trigger the cleaning up of the subtables.

5 Likes

Genius. I’d come across IsFromTable before, but hadn’t thought of a way to put it to use. Thanks!

Just found another way to do this (I think): If you create a button with the criteria as:

BrokenLookupReferenceColumn.RowId().IsBlank()