Deleted record but related records still have a reference to it

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
Hi,

I have two tables "A" and "B" where "A" has a field that is a numeric reference to "B". 

I have an "A" record, "a", that contains a reference to a "B" record, "b", but when I delete "b", "a" still contains the id of "b" in the reference field when I do a query on "a" (e.g. via API_GetRecordInfo).  However, "a" appears correct via the web interface and doesn't display a reference to "b" at all.

I was wondering if this is expected behavior?  I also noticed that "a" didn't get an updated update_id after I deleted "b".  Is there any way for changes like this to automatically propagate to related records?

Thanks!
Photo of Danny Im

Danny Im

  • 82 Points 75 badge 2x thumb

Posted 1 year ago

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

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 27,694 Points 20k badge 2x thumb
QuickBase does not support "Cascade Delete" behavior so this is the expected behavior. But it would not be difficult to implement this behavior in script with or without using a Service Worker (there are two entirely different solutions one of which would use a SW). Either way automatically deleting records might cause other issues if the records in question had yet other relationships to other tables.
Photo of Danny Im

Danny Im

  • 82 Points 75 badge 2x thumb
I wasn't really thinking of deleting the related records, but more of a "ON DELETE SET NULL" type of behavior.  I see that in the web interface record "a" doesn't appear to have any references to "b" anymore, which doesn't match the response returned by the API. 

Thanks for the prompt response.
Photo of Matthew Neil

Matthew Neil

  • 31,478 Points 20k badge 2x thumb
What is the reason you are using the API to see if record B has a number in the reference field?

If you are looking to find connected or not connected values for some query?  If so, and that the GetRecordInfo is causing issues.  You can use a lookup field from the relationship that is always populated to filter your results.