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

Case update in API V3 makes case reassign if contact_id is not set

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.2.4
    • Fix Version/s: 4.3.0
    • Component/s: CiviCase
    • Labels:
      None

      Description

      When trying to call Case Close using CiviCRM API V3, something strange happened:

      Original Case was Closed (Resolved), but all activities in it deleted
      New Case was created as reassign of the original Case - to the same contact, still in status Ongoing.

      I have tried to analyze this and found following:

      civicrm_api3_generic_update calls Case.get using civicrm api v3 ($existing = civicrm_api($apiRequest['entity'], 'get', $seek)

      It then adds the parameters to the request:

      $existing = array_pop($existing['values']);
      $p = array_merge($existing, $apiRequest['params']);
      return civicrm_api($apiRequest['entity'], 'create', $p);

      However, in $p is 'contact_id' now not a value, but array:

      [contact_id] => Array
      (
      [1] => 1
      )

      Then, in _api_case_update is following code:

      // check for same contact id for edit Client
      if ($params['contact_id'] && !in_array($params['contact_id'], $origContactIds))

      { $mCaseId = CRM_Case_BAO_Case::mergeCases($params['contact_id'], $params['case_id'], $origContactId, NULL, TRUE); }

      because $params['contact_id'] is not value, but array, the condition matches (even though actually contact_id and origContstsId[1] have the same value
      ... and mergeCases is called

      I am not sure, in which place is the best to fix this issue. I am posting it here ... and for my personal reasons will implement some temporary fix.

      Regards,

      Dexter

        Attachments

          Activity

            People

            • Assignee:
              colemanw Coleman Watts
              Reporter:
              dexter dexter
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: