Skip to content

Commit

Permalink
Merge pull request #19701 from civicrm/5.35
Browse files Browse the repository at this point in the history
5.35
  • Loading branch information
eileenmcnaughton authored Mar 1, 2021
2 parents a6ba1fe + c7f7155 commit da176e2
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions CRM/Case/Form/CustomData.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,26 @@ public function formatCustomDataChangesForDetail($params) {
if (!empty($customFieldId) && is_numeric($customFieldId)) {
// Got a custom field ID
$label = civicrm_api3('CustomField', 'getvalue', ['id' => $customFieldId, 'return' => 'label']);
$oldValue = civicrm_api3('CustomValue', 'getdisplayvalue', [
'custom_field_id' => $customFieldId,
'entity_id' => $this->_entityID,
'custom_field_value' => $this->_defaults[$customField],
]);
$oldValue = $oldValue['values'][$customFieldId]['display'];
$newValue = civicrm_api3('CustomValue', 'getdisplayvalue', [
'custom_field_id' => $customFieldId,
'entity_id' => $this->_entityID,
'custom_field_value' => $newCustomValue,
]);
$newValue = $newValue['values'][$customFieldId]['display'];

// Convert dropdown and other machine values to human labels.
// Money is special for non-US locales because at this point it's in human format so we don't
// want to try to convert it.
$oldValue = $this->_defaults[$customField] ?? '';
$newValue = $newCustomValue;
if ('Money' !== civicrm_api3('CustomField', 'getvalue', ['id' => $customFieldId, 'return' => 'data_type'])) {
$oldValue = civicrm_api3('CustomValue', 'getdisplayvalue', [
'custom_field_id' => $customFieldId,
'entity_id' => $this->_entityID,
'custom_field_value' => $oldValue,
]);
$oldValue = $oldValue['values'][$customFieldId]['display'];
$newValue = civicrm_api3('CustomValue', 'getdisplayvalue', [
'custom_field_id' => $customFieldId,
'entity_id' => $this->_entityID,
'custom_field_value' => $newCustomValue,
]);
$newValue = $newValue['values'][$customFieldId]['display'];
}
$formattedDetails[] = $label . ': ' . $oldValue . ' => ' . $newValue;
}

Expand Down

0 comments on commit da176e2

Please sign in to comment.