CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Can't use api to get custom value for a multi-option custom field
Pages: [1]

Author Topic: Can't use api to get custom value for a multi-option custom field  (Read 938 times)

bouton

  • Guest
Can't use api to get custom value for a multi-option custom field
December 29, 2011, 07:33:00 am
I have been trying with no luck to use the api to return contacts which have one option selected from a multi option custom field.

If I do
<code>
$params = array(
  'version' =>'3',
  'return' =>'custom_18,display_name'
)
$results=civicrm_api("Contact","get", $params);
</code>
I am returned
<code>
"1":{
  "contact_id":"1",
  "display_name":"Test Society 1",
  "contact_is_deleted":"0",
  "civicrm_value_information_3_id":"11",
  "custom_18":["fossils"],
  "id":"1"
},
"2":{
  "contact_id":"2",
  "display_name":"Test Society 2",
  "contact_is_deleted":"0",
  "civicrm_value_information_3_id":"11",
  "custom_18":["fossils","marine"],
  "id":"2"
}
</code>

But if I do

<code>
$params = array(
  'version' =>'3',
  'custom_18' =>'fossils', -- or  'custom_18' =>array('fossils'),
  'return' =>'custom_18,display_name'
)
$results=civicrm_api("Contact","get", $params);
</code>
I am returned
<code>
"1":{
  "contact_id":"1",
  "display_name":"Test Society 1",
  "contact_is_deleted":"0",
  "civicrm_value_information_3_id":"11",
  "custom_18":["fossils"],
  "id":"1"
}
</code>

It is only picking up those contacts where only one item is in custom_18.
This has had me stumped and I have gotten so I can't progress much further.
Pointers would be appreciated
thanks

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Can't use api to get custom value for a multi-option custom field

This forum was archived on 2017-11-26.