From 28f7a9b19f3c41aa65f4dd0a1cc3fa38c7e5341e Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Sat, 4 Jan 2020 16:19:29 +0000 Subject: [PATCH] Fix activity.case_id token to always display the first case ID --- CRM/Activity/Tokens.php | 5 +++++ 1 file changed, 5 insertions(+) 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)