}
if ($this->isMoneyField($field)) {
$currency = $this->getCurrency($row);
+ if (empty($fieldValue) && !is_numeric($fieldValue)) {
+ $fieldValue = 0;
+ }
if (!$currency) {
// too hard basket for now - just do what we always did.
return $row->format('text/plain')->tokens($entity, $field,
* @param int $id
*
* @return string
+ *
+ * @throws \CRM_Core_Exception
*/
protected function getCustomFieldName(int $id): string {
foreach ($this->getTokenMetadata() as $key => $field) {
return $key;
}
}
+ throw new CRM_Core_Exception(
+ "A custom field with the ID {$id} does not exist"
+ );
}
/**
*/
protected function getCustomFieldValue($entityID, string $field) {
$id = str_replace('custom_', '', $field);
- $value = $this->prefetch[$entityID][$this->getCustomFieldName($id)] ?? '';
- if ($value !== NULL) {
- return CRM_Core_BAO_CustomField::displayValue($value, $id);
+ try {
+ $value = $this->prefetch[$entityID][$this->getCustomFieldName($id)] ?? '';
+ if ($value !== NULL) {
+ return CRM_Core_BAO_CustomField::displayValue($value, $id);
+ }
+ }
+ catch (CRM_Core_Exception $exception) {
+ return NULL;
}
}