- //not standard - but some api did this so guess we should keep - cheap as chips
- $returnArray[$key] = $val;
+ //not standard - but some api did this so guess we should keep - cheap as chips
+ $returnArray[$key] = $val;
+
+ // Shim to restore legacy behavior of ContactReference custom fields
+ if (!empty($fieldInfo[$id]) && $fieldInfo[$id]['data_type'] == 'ContactReference') {
+ $returnArray['custom_' . $id . '_id'] = $returnArray[$key . '_id'] = $val;
+ $returnArray['custom_' . $id] = $returnArray[$key] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $val, 'sort_name');