0

I have a custom field that can be inserted multiple times in a contact. I'm trying to get the right syntax for the API to display an array with the different results.

Here what I'm trying: civicrm/extern/rest.php?entity=Contact&action=get&api_key=userkey&key=sitekey&json={"sequential":1,"return":"custom_40","id":900}

I thought that "sequential" would give multiple results but it's showing only one

{

"is_error": 0,
"version": 3,
"count": 1,
"id": 900,
"values": [
    {
        "contact_id": "900",
        "civicrm_value_fellowships_3_id": "305",
        "custom_40": "2007-06-30 00:00:00",
        "id": "900"
    }
]

}

1 Answer 1

1

Contact API sends one result per contact. In case if you want to retrieve all custom field value(multiple) of a contact than you need to use CustomValue api. Snippet for reference

REST:

http://localhost/drupal7/sites/all/modules/civicrm/extern/rest.php?entity=CustomValue&action=get&api_key=userkey&key=sitekey&json={"sequential":1,"return":"custom_81,custom_80","entity_id":296,"entityType":"contact"}

PHP

$result = civicrm_api3('CustomValue', 'get', [
  'sequential' => 1,
  'return' => ["custom_81", "custom_80"],
  'entity_id' => 296,
  'entityType' => "contact",
]);

entity_id = contact id

return = custom fields

HTH

Pradeep

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.