CRM-5577 Delete Contacts - Associated notes are not deleted for contact when contact is deleted.

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 3.1
    • Fix Version/s: 3.1
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      I'm having to reimport and delete a few times to get everything right. I noticed that the notes associated with a particular contact id are not getting deleted when I use the delete contacts through the CiviCRM menu. Normally, this wouldn't be a problem, but I'm resetting the auto-increment when I delete everything to start over for this import. Thus, what ends up happening is that I end up with previous notes mis-matched to the new contact id.

      When you delete a contact, all the notes associated with that contact id should be deleted, or at least an additional option provided to delete associated notes for the contact. As a work around, I'm deleting the notes manually when I restart the import. For most users, this won't be a problem as the auto-increment will prevent old notes from being associated with new contact id's. It just means that the civicrm_notes table will grow and will contain contact_id's that no longer existing.

      Solution:

      Provide a delete option for notes associated with current contact_id's or just perform a cascade delete for civicrm_notes for notes associated with a particular contact_id.

      I was testing in CiviCRM 3.1.beta3

        Attachments

        1. Corrected ScreenShot.jpg
          62 kB
          Tracy Smith
        2. Search Results.jpg
          33 kB
          Tracy Smith

          Activity

          [CRM-5577] Delete Contacts - Associated notes are not deleted for contact when contact is deleted.
          David Greenberg added a comment -

          Tracy - Want to make sure we're on the same page here. The contact_id column in civicrm_note table stores the ID of the contact who CREATED the note (not the ID of the contact that the note is ABOUT). Therefore the constraint on civicrm_note.contact_id is 'On delete set null' - because we don't want the Notes to be deleted just because the person who wrote the note is no longer in the system. I don't think we'd want to change this behavior.

          The link between the note record and the contact (or other object) that the note is ABOUT, is stored in the entity_table + entity_id column. I did test deleted the contact that the note was 'about' - and the associated note rows are deleted properly (at least in my tests).

          Tracy Smith added a comment -

          David - Ah that makes sense, but I just did a test and here is what I'm seeing.

          Find a contact from the Search -> Find Contacts
          Click the checkbox for a contact with Notes.
          Select Delete from the select box next to the PRINT button, and click Go.
          The contact is deleted, but when I view the civicrm_notes table, the note associated with that contact is still there.

          Perhaps, when you delete a contact a different way the notes are being deleted correctly? I'll attach a screenshot so you can see.

          Tracy Smith added a comment -

          I just did a test on the Sandbox site.

          Created a new contact: Tracy Smith with CID: 104
          Then created a note for this contact.
          Then searched for the contact and selected delete.
          Deleted the contact, did another search to confirm it is gone.

          The URL when viewing the note originally was:

          http://sandbox.civicrm.org/civicrm/contact/view/note?action=view&reset=1&cid=104&id=98&selectedChild=note

          I'm assuming then that the civicrm_note ID = 98

          I can't check on the backend, but I'm guessing that this note is still there.

          The note contained a link to this issue and the Subject contained CRM-5577 on it.

          Hope this helps, let me know if you need me to do anymore testing or checking.

          Thanks,

          Tracy

          David Greenberg added a comment -

          Kurund - Can you check if the note that Tracy referenced in his last comment is still present in sandbox DB?

          Kurund Jalmi added a comment -

          Confirmed there is no Note with with subject containing CRM-5577. I was also not able to replicate it on my local and sandbox.

          Tracy Smith added a comment -

          Hmmm....I'll try it again, step-by-step and see if I can replicate it and report back.

          Erik Hommel added a comment -

          I have the same problem after I have done a conversion. The notes I have created are not deleted if I delete the contact.

            People

            • Assignee:
              Kurund Jalmi
              Reporter:
              Tracy Smith

              Dates

              • Created:
                Updated:
                Resolved: