3 Replies Latest reply on Jan 10, 2015 8:08 AM by garydr

    Mysterious Record deletion

    garydr

      Hello;

       

      I'm working on a solution for a school. In one part of the solution I have to organize people into families. What I have done is create a contact table that holds both the family records as well as the people records.

      Then there is a Related table that links families to people in a many to many relationship. The reason it's many to many is that a child may be part of more than one family in the case of joint custody.

       

      Contact records have, among other fields:

      ID - record ID

      contactType - identifies if this is a person, family, church or business.

       

      CONTACT(family)     RELATED     CONTACT(person)

                            ID   >>  id_family

                                        id_person  >>   ID

      The relationship between CONTACT(family) & RELATED is set to allow record creation. Neither relationship is set to delete related records.

      On the family layout there is a portal using the TO, RELATED, listing all the family members. Here is the sequence of events that leads to the problem.

      1. I create a CONTACT(family) record

      2. I create a couple of CONTACT(person) records.

      3. I link the person records to the family by creating appropriate RELATED records.

      4. Now I decide to break the relationship between the family and one of the persons. I delete the RELATED record using a script that first confirms that the user really wants to delete this and then does a Delete Portal Row [no Dialog].

       

      The problem is that BOTH the RELATED record and the CONTACT(person) record are deleted! This happens even if I open one of my developer layouts that only lists RELATED records. If I manually delete the RELATED record, the CONTACT(person) record also is deleted. The CONTACT(family) record remains intact.

       

      Help with this would be greatly appreciated.

      Thanks in advance.

      Gary

        • 1. Re: Mysterious Record deletion
          mtwalker

          This may have been the first thing you did but have you confirmed that the RELATED TO is actually based on the Related table and not the Contacts table by mistake?

          • 2. Re: Mysterious Record deletion
            keywords

            Re: "Neither relationship is set to delete related records" the behaviour you describe certainly sounds like this is the cause, even though you say it isn't.

             

            In addition to Todd's suggestion, you should carefully check that the "delete related" option is not checked by mistake; it sounds as if it might be checked to delete the CONTACT record when the RELATED record is deleted.

             

            Another possibility:  is RELATED merely a join table? If so, make sure it is set up correctly as its own separate table, and that the relationships it uses are both unchecked in both directions.

            • 3. Re: Mysterious Record deletion
              garydr

              In another forum it was pointed out to me that the setting "Delete related records in this table when a record is deleted in the other table" is not context sensitive. So although the portal I was deleting in did not have this set, it was set somewhere else in the graph.

               

              Thanks for your help.

              Gary