Automatically Remove Empty/Deleted Reference Field Entries?

Options
I have several tables with fields referencing entries to other tables. I am now realizing (later than is ideal), that when an entry is deleted in one table, it is not removed from a reference field in another table. Rather, when it is a list-type reference field, a blank entry remains, as seen here:
[Screenshot 2022-09-29 102755.png]This is causing issues in my app, because it looks like there are associated items, but there aren't.  

Obviously, I wish that I had added a step to remove reference field entries from other tables when I delete a given record. I can still do that, but it'll take a lot of time. Is there a setting I can enable that will prevent these blank fields from remaining?

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    There is not a setting to do this, but it shouldn't be that difficult to do.

    You can create a background task to do this and use query all records in stream mode, foreach, and then an edit record.
  • Kyan Lynch
    Options
    Thanks for that suggestion! Makes sense. What query method can I use to find these blank items in a list? Would it be where record.key_words contains ""? 
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    you can just use the filter_empty filter. IT will do everything for you and return a new array that has no empty values.