Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-5758

Implement new business rules for handling cases when two contacts are merged

    Details

    • Type: Task
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.2
    • Component/s: CiviCase
    • Labels:
      None

      Description

      NOTE: This issue is related to CRM-5598 and some processes / code should be shared.
      NOTE: This issue is related to CRM-5673 since the rule to retain the original case with a deleted flag is dependent on the site being configured to 'move contacts to trash' (i.e. dupe contact is NOT deleted and neither is the original case). Please coordinate this issue with Piotr's work 5673.

      When a contact with associated case(s) is merged with another contact, the following steps are required:

      • Make a complete copy of each case (and it's case activities) associated with the dupe contact and assign the copied case to the primary (target) contact
      • When copying case activities, if an activity target_contact_id = dupe contact id, then the copy should set target_contact_id = primary (merged to) contact id. This 'fixes' the case 'client' for these activities to point to the right contact id.
      • Case roles (relationships linked to this case via relationship.case_id) need to have both the case_id and the contact_id_a values updated (contact_id_a becomes the contact_id of the primary (merged to) contact who is now 'the client').
      • Auto-add an activity on the new case (activity type = "Merge Case") with subject "Case 1234 copied from contact id 516 to contact id 923 via merge. New Case ID is 3211."
      • Mark the original case, and related case activities as deleted (is_deleted = 1).

      NOTE: If 'move contacts to trash' feature is enabled, then the dupe contact will be moved to trash (is_deleted = 1) as part of CRM-5673. If it's NOT enabled, then I guess the 'copied' case would get deleted via FK on delete cascade. This might mean we shouldn't bother with the case copying step - but not sure if it's worth putting that exception in the code since I think most sites will use the 'move contact to trash' feature.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dgg David Greenberg
                Reporter:
                dgg David Greenberg
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: