1 Reply Latest reply on Jun 3, 2012 8:38 PM by philmodjunk

    Deleting Related Records

    Vinny

      Title

      Deleting Related Records & Popups

      Post

      I have a relationship: Customers >- Types.

      On the customers layout, there is a popup to select a customer "type".  I would like to allow the user to delete a "type" even if it is currently related to a customer (or customers).

      The result I would like is: for those customer records which were related to the now deleted type, the popup will be blank as a result of the Type being deleted.

      The popup is using a foreign key to the Types table's ID field (auto serial on create), and a value list of all types from the types table (first field ID, second field type name).

      When a type is deleted, any customer record which was linked to it, now shows the old type's ID number in the popup.  I would expect that now that the child item has been deleted, the popup / related field would revert to "" (nothing).

      What is the best way to protect / remedy this?

      I can easily write a script to go to a customers layout and remove all the "broken" links to the types table, but this seems like a lot of work todo...

      Is there a better way of looking at this?  FYI, I have many other instances of this issue; this is just a basic one. However, if I can make a strategy for this example, I'm hoping to re-use it across my solution.

      Also, this is a case where I don't want to stop the user from deleting the type record even though there are parent records using it.  I simply want the parent record's reference to be returned to "nothing".

        • 1. Re: Deleting Related Records & Popups
          philmodjunk

          Deleting a record in Types does not alter data stored in any field in Customers.

          You may want to use a drop down list instead of a pop up menu for this. With a drop down list, you can put it behind a "name" field from the Types table that is set up in behavior to prevent access when in browse mode. Give this field a non transparent fill color and the drop down list field will remain hidden behind the "name" field until the user clicks on it or tabs into it. Since the name field is from Types, deleting the related types field will result in an empty field that still obscures the ID number stored in the drop down.