CRM-20345 - Fix retrieval of primary client
authorColeman Watts <coleman@civicrm.org>
Wed, 29 Mar 2017 03:22:00 +0000 (23:22 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 29 Mar 2017 03:22:00 +0000 (23:22 -0400)
CRM/Case/BAO/Case.php

index e76b348cd38c4e8982bf2fd785db4a1175af79e8..14946c4c1334aa21217a1363f692c95661df8657 100644 (file)
@@ -329,7 +329,8 @@ WHERE civicrm_case.id = %1";
  LEFT JOIN  civicrm_case_contact ON civicrm_case_contact.contact_id = contact_a.id
  LEFT JOIN  civicrm_email ce ON ( ce.contact_id = contact_a.id AND ce.is_primary = 1)
  LEFT JOIN  civicrm_phone cp ON ( cp.contact_id = contact_a.id AND cp.is_primary = 1)
-     WHERE  civicrm_case_contact.case_id = %1";
+     WHERE  civicrm_case_contact.case_id = %1
+     ORDER BY civicrm_case_contact.id";
 
     $dao = CRM_Core_DAO::executeQuery($query,
       array(1 => array($caseId, 'Integer'))
@@ -3074,6 +3075,7 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
     $clients = array();
     $caseContact = new CRM_Case_DAO_CaseContact();
     $caseContact->case_id = $caseId;
+    $caseContact->orderBy('id');
     $caseContact->find();
 
     while ($caseContact->fetch()) {