diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index bda424a9eff9..d936c32c3bf0 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1141,6 +1141,7 @@ public static function getRelatedContacts($caseID, $includeDetails = TRUE) { } $values = []; + $caseClientCondition = !empty($caseInfo['client_id']) ? "AND cc.id NOT IN (%2)" : ''; $query = << [$caseID, 'Integer'], - 2 => [implode(',', $caseInfo['client_id']), 'String'], ]; + + if ($caseClientCondition) { + $params[2] = [implode(',', $caseInfo['client_id']), 'CommaSeparatedIntegers']; + } $dao = CRM_Core_DAO::executeQuery($query, $params); while ($dao->fetch()) {