Automatically delete rows in linked tables

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

Hi,

I have 2 tables : Products is a child of Orders.

I want that when an order is deleted, the products contained in the order are also deletd, is it possible ?

Thanks !

Bastien

Photo of Bastien

Bastien

  • 0 Points

Posted 4 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,264 Points 20k badge 2x thumb
Select a record to display and click the "Cascade Delete" option as shown on the attached screenshot.

Cascade Delete
https://haversineconsulting.quickbase.com/db/bj3yt647a?a=td


I made this very demo rapidly so there is no provision for confirming the deletion before proceeding - but you should add a dialog so that records are not accidentally deleted..

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=408
There is no native function for cascade deletion, although there are advanced methods which can be done with programming as Dan is demoing above.

I usually make a formula checkbox field on the Parent record with a value of true and then look that up down to the children.  Then delete them from time to time. You can filter off orphans from your reports using that field.
Photo of Bastien

Bastien

  • 0 Points
Hi Mark, thank you for your answer, that is what I am doing right now as a maintenance :)
Photo of Bastien

Bastien

  • 0 Points
Hi, thanks for your answer, this solution seems quite difficult to implement, I think i might stick to my current solution
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,264 Points 20k badge 2x thumb
It took me 20 minutes. Where is the difficulty?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,264 Points 20k badge 2x thumb
I updated the application and pastie to use QuickBase's native QB.Dialog.confirm() to throw up a dialog which will prompt you to confirm deletion of the Parent and Children records. See attached screenshot.

Cascade Delete
https://haversineconsulting.quickbase.com/db/bj3yt647a?a=td


Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=408


The only thing you need to do to implement this feature is to first set up the Image Onload Technique in your application (which consists of (1) creating two user defined variables named [iol] and [/iol], (2) creating one user defined page named module.js and (3) defining a simple formula for the magic field [-] and placing it on the form) is to set the following constants appropriate for your application:

    var dbidParent = "bj3yt647a";
    var dbidChild = "bj3yt648v";
    var relatedParentFid = "7";
    var apptoken = "bh2zgxtddyi4erbmsmrwhc39if9q";
Photo of Keith

Keith, Champion

  • 1,214 Points 1k badge 2x thumb
We offer a Cascase Delete QuickBase Trigger

demo app:  https://juicedtech.quickbase.com/db/bkauvdihe

we'll set it up and manage it for you.



Keith