diff --git a/CRM/Activity/Tokens.php b/CRM/Activity/Tokens.php index 98844043299e..825c120c9890 100644 --- a/CRM/Activity/Tokens.php +++ b/CRM/Activity/Tokens.php @@ -197,6 +197,11 @@ public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefe elseif (in_array($field, ['campaign'])) { $row->tokens($entity, $field, $this->campaigns[$activity->campaign_id]); } + elseif (in_array($field, ['case_id'])) { + // An activity can be linked to multiple cases so case_id is always an array. + // We just return the first case ID for the token. + $row->tokens($entity, $field, is_array($activity->case_id) ? reset($activity->case_id) : $activity->case_id); + } elseif (array_key_exists($field, $this->customFieldTokens)) { $row->tokens($entity, $field, isset($activity->$field)