I am using civicrm on drupal 7. I have configured my Civi instance to accept external REST API calls with authentication.
I want to get all the values from a set of custom fields associated with an organization sub-type.
I am making a call something like this:
$contacts = civicrm_api4('Contact', 'get', [
'select' => [
'id',
'display_name',
'my_custom_field_set.*',
],
'join' => [
['my_custom_field_set AS my_custom_field_set', 'LEFT'],
],
'where' => [
['my_custom_field_set.name', 'IS NOT NULL'],
['contact_type', '=', 'Organization'],
['contact_sub_type', '=', 'CLC'],
],
]);
This mostly works... except for 5 entries in my database that get skipped. The five failures are all part of another sub-type: ICT Program Client
which has some other fields and relationships associated with it.
If I remove the sub-type CLC
WHERE constraint it works. But I would prefer to understand why the presence of the other sub-type on a contact would make the query fail.
The 5 failures are definitely of sub-type CLC
.