Delete child records when parent is deleted (alternative to "Is a part of?")

Child records are connected to the parent record via a column of type Ref.
When you enable Is a part of?, all child records will be automatically deleted, when parent is deleted.

But what if you have more than one Ref column in your child table? Then you can enable "Is a part of?" only in one column. So when you delete the parent, only the child records referenced by this column will be deleted. All other will stay as orphan. You can see it by the yellow triangle next to the Parent's Key value. 

Fabian_Weller_0-1675422679892.png

There are two ways to delete the child records: Via Action or via Bot.

Via Action
There is a nice Guide by @Steve. The downside is that this Grouped Action will not appear in the upper right corner as we are used to. You can only place it Primary or prominently.

Fabian_Weller_1-1675423209691.png

Via Bot

  1. Create a new Bot
    Event Type: Deletes only
    Table: Parent Table
  2. Add a Step
    Run a Data action
    Run action on rows
    Referenced Table: Child Table
    Referenced rows: The column that's called Related Whatsoever
    Referenced Action: Delete

The downside is, that the child records will be vissible in the app until the next sync or background sync. At least some seconds. This could confuse. 

You can add a format rule to hide these rows
For this data: Child Table
If this condition is true: 
AND(NOT(IN([Ref_Column],Parent_Table[Key])) , CONTEXT("ViewType")<>"Form")
Meaning: When the Parent referenced in the Ref_Column does not exist. And when it's not in a form view.
Format these columns and actions: All
Icon: Nothing
Text Color: Write the word "Transparent"
Text Size: 0.2

Now all what is left is a blank row with a tiny little yellow triangle. This row will disappear after the next sync or background sync.

Fabian_Weller_2-1675424095805.png

 

7 0 1,105
0 REPLIES 0
Top Labels in this Space