From 88fb9a982aaa2a0509b9c909cca5074e8fd2c34b Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Tue, 14 Feb 2023 18:46:43 +0000 Subject: [PATCH] update entity mapping logic for profile fields to include contact subtypes --- api/v3/Profile.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/api/v3/Profile.php b/api/v3/Profile.php index 78306eb6ec..4c4f78355e 100644 --- a/api/v3/Profile.php +++ b/api/v3/Profile.php @@ -629,8 +629,19 @@ function _civicrm_api3_order_by_weight($a, $b) { */ function _civicrm_api3_map_profile_fields_to_entity(&$field) { $entity = $field['field_type']; - $contactTypes = civicrm_api3('contact', 'getoptions', ['field' => 'contact_type']); - if (in_array($entity, $contactTypes['values'])) { + // let's get the contact types and subtypes so that we can change the entity + // of such fields to 'contact' + $result = civicrm_api3('ContactType', 'get', [ + 'return' => ["name"], + 'options' => ['limit' => 0], + ]); + + $contactTypes = []; + foreach ($result['values'] as $type) { + $contactTypes[$type['id']] = $type['name']; + } + + if (in_array($entity, $contactTypes)) { $entity = 'contact'; } $entity = _civicrm_api_get_entity_name_from_camel($entity); -- 2.25.1