Merge pull request #13280 from aydun/tokenrow_fix
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 3 Jan 2019 15:14:13 +0000 (02:14 +1100)
committerGitHub <noreply@github.com>
Thu, 3 Jan 2019 15:14:13 +0000 (02:14 +1100)
Fix  \Civi\Token\TokenRow::customToken() failure if field is not set

1  2 
Civi/Token/TokenRow.php

index 5a223beb33a33f2657111146053c53918b357994,efe5275f2af2802bf3a7af8e3c24e5c2e0b7f215..cb5982f004bfe365866f8478512995f752cc47ae
@@@ -136,13 -136,14 +136,14 @@@ class TokenRow 
     */
    public function customToken($entity, $customFieldID, $entityID) {
      $customFieldName = "custom_" . $customFieldID;
-     $fieldValue = civicrm_api3($entity, 'getvalue', array(
+     $record = civicrm_api3($entity, "getSingle", [
        'return' => $customFieldName,
-       'id' => $entityID,
-     ));
+        'id' => $entityID,
+     ]);
+     $fieldValue = \CRM_Utils_Array::value($customFieldName, $record, '');
  
      // format the raw custom field value into proper display value
 -    if ($fieldValue) {
 +    if (isset($fieldValue)) {
        $fieldValue = \CRM_Core_BAO_CustomField::displayValue($fieldValue, $customFieldID);
      }