How do you Delete in cascading fashion?

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

How do you do a cascading delete, where deleting a parent record would also delete all associated child records?

Photo of Krishna

Krishna

  • 10 Points

Posted 5 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,792 Points 50k badge 2x thumb
I don't think that's a native function. What I typically do is to have reports of orphan children with no Parents and set up a monthly subscription to have someone delete the orphans.
Photo of Krishna

Krishna

  • 10 Points
how do you identify orphaned child records?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,792 Points 50k badge 2x thumb
I usually make a checkbox formula field on the Parent such as [Project Exists?] with a formula of true.

Then I look that up down to the Child. An orphan will have false in that lookup field since is has no connection to a Parent.
Photo of Sediq

Sediq

  • 0 Points
Hi,
I need to make sure that when a Master record is being deleted it should give the user a msg saying that there are some Child records in child table, and then if the user proceeds the Master record along with their Child Records are also delete. Please guide me through.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 29,924 Points 20k badge 2x thumb
Code similar to this should do the job if invoked from a button on the view page of the parent record:

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


The script used the global variable kRid which is the decimal value of the [Record ID#] being displayed. You would have to specify your parent and child dbid's and the fid of the [Related Parent] in the child table. Test it outside your live application as API_PurgeRecords cannot be undone if there is a mistake.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,792 Points 50k badge 2x thumb
QuickBase does not natively support cascading deletion of children.  What most users do is to filter orphans off reports and then say once a month have subscriptions reports delivered to a user to mass delete them using the More button.