I just noticed an error on a site I maintain. Some custom code uses apiv4 to return a value from a set of custom fields (on individual contacts) and that function now throws an error:

API_Exception: Invalid field 'Employment_History.relationshipID' in Civi\Api4\Query\Api4SelectQuery->getField() (line 474 of /var/www/html/sitename/sites/all/modules/contrib/civicrm/Civi/Api4/Query/Api4SelectQuery.php).

Doing some tests, it seems that sometime between 5.15.1 and 5.27.4 (issue still exists in current version, 5.28.2) apiv4 stopped being able to return custom fields that can have multiple values.

I tested this by creating two sets of fields that are identical other than one being set to allow multiple entries. Only one shows up in the apiv4 explorer.

I'm going to update the working site to isolate the version where the problem started.

apiv4 explorer 5.15.1

apiv4 explorer 5.27.42

  • I remember something about a "serializable" concept being introduced probably in that range but I would have thought there was something that updated the config for those fields as part of the upgrade. If you resave the custom field definition does that fix it? What type of field is it?
    – Demerit
    Aug 20, 2020 at 19:06
  • This PR and here's the upgrade line: github.com/civicrm/civicrm-core/pull/16992/…
    – Demerit
    Aug 20, 2020 at 19:08
  • even if I create new fields this problem happens. create new fieldset that is single entry and it works; add a new fieldset that is multiple entry it will not be available in the api explorer and will throw the error noted.
    – ericG
    Aug 20, 2020 at 19:19
  • 1
    looks like it started with 5.22.0
    – ericG
    Aug 20, 2020 at 19:29
  • tested this on multiple sites, including one of the civi demo sites. multiple entry sets are no longer identified by apiv4 demo.circle-interactive.co.uk/civicrm/api4#/explorer/Contact/… (there's a test single and test multiple set; only one shows)
    – ericG
    Aug 20, 2020 at 20:13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.