1

I would like to retrieve both the value as well as the label from a custom field using the api, but it only seems possible to retrieve the value. I wonder if this is possible, would surely help me a lot!

2

I assume you mean a drop-down field? You then need to do another lookup on the OptionValue to get the label, e.g. from the api explorer:

    $result = civicrm_api3('OptionValue', 'get', [
      'return' => ["label"],
      'option_group_id' => "custom_marital_status",
      'value' => "S",
    ]);

gives you

"is_error": 0,
    "version": 3,
    "count": 1,
    "id": 866,
    "values": [
        {
            "id": "866",
            "label": "Single"
        }
    ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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