Restrict deletion if referenced id is being used

Hi, we were wondering if it's possible to restrict the deletion of a row in a table if the id for that row is currently being used by another table that references it, like it would if you set "on delete", "restrict" on a relational database (we're using BigQuery so it's not possible to set that restriction from the database itself). 

With the default behavior, if a row is deleted and another table references that id, it will still allow to delete it and the referenced record is untouched with an orphan referenced id. I see the "Is a part of?" basically would allow to do a "cascade" deletion, but that's not what we want. In the deletion behavior there's a "only if this condition is true" which might be the right way to do this, but we're not sure of what expression to use for it. Edit: Tried COUNT(REF_ROWS("table1", "refColumn")) = 0 and it hides the delete button for those that have referenced records, kind of works.

Thanks.

Solved Solved
0 3 111
1 ACCEPTED SOLUTION


@nlozano wrote:

Tried COUNT(REF_ROWS("table1", "refColumn")) = 0 and it hides the delete button for those that have referenced records


Seems like a good approach. Besides not displaying the button to users, it actually disables the action altogether--e.g., if it's included in a grouped action. Do you think what you've done is insufficient for some reason?

View solution in original post

3 REPLIES 3


@nlozano wrote:

Tried COUNT(REF_ROWS("table1", "refColumn")) = 0 and it hides the delete button for those that have referenced records


Seems like a good approach. Besides not displaying the button to users, it actually disables the action altogether--e.g., if it's included in a grouped action. Do you think what you've done is insufficient for some reason?

Thanks for the response. It's okay, it works fine like this. I just thought hiding the "delete" button without providing a reason why it's hidden could be unintuitive to users, but hopefully it won't be an issue as long as we explain it somewhere.

Another simpler expression to try would be 

ISBLANK([Rev Ref Column in the parent table])

Top Labels in this Space