3

We'd like to retrieve a filtered list of the multiple choice options for one of our custom fields through the API, with the output being both the Label and the Value for that field (so we can use it in a dropdown). Is there an API call to get all multiple choice options for a specific custom field? Or do we need to write a query directly against the database table? Thanks.

3

Yes, if you visit your api explorer you'll be able to play with this in detail, but the api call you probably want is:

civicrm_api3('contact', 'getoptions', array('field' => 'custom_123'));

where 123 is the id of your custom field.

By the way, you haven't said how/where you are developing this form, but if it's on your own site with access to the ajax api, then a big shortcut for you would be to simply drop in an entityRef field (entity type = "option_value") and given the correct option group it will do everything else for you.

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.