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) »
  • Custom address fields w/ API Get
Pages: [1]

Author Topic: Custom address fields w/ API Get  (Read 793 times)

Laryn

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 4
    • CEDC
  • CiviCRM version: 4.6.x
  • CMS version: Drupal 7
Custom address fields w/ API Get
December 13, 2013, 02:10:47 pm
I am having a hard time figuring out how to pull custom fields that are associated with an address (rather than a contact) via the API. A regular Address > Get doesn't pull the custom fields, and a Custom Value > Get doesn't seem to work (or I don't know how to pull it out of there correctly at any rate).

Has anyone done this before?
CEDC...social justice by design

*Get support on the new CiviCRM help site. /laryn

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Custom address fields w/ API Get
December 13, 2013, 09:46:04 pm
custom_value get is correct. What params are you using? A little experimentation in the api explorer should give you the right combo.
Try asking your question on the new CiviCRM help site.

Laryn

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 4
    • CEDC
  • CiviCRM version: 4.6.x
  • CMS version: Drupal 7
Re: Custom address fields w/ API Get
December 14, 2013, 11:13:19 am
Thanks, Coleman. I have been trying in the API Explorer to no avail. With Custom Value > Get, I've tried:
  • entity_id = id (from the civicrm_address table for the relevant address; but it pulls up info for custom contact fields for a contact_id instead of an address id)
  • entity_id = contact_id (for the relevant contact; and although it returns custom values associated with the contact directly, it does not return the ones associated with the contact's address)
  • entity_id = contact_id & return.custom_X=1 (for the relevant contact; returns 0)

Maybe you have an idea what I'm doing wrong. (For what it's worth, this happens on the demo site, too).
CEDC...social justice by design

*Get support on the new CiviCRM help site. /laryn

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Custom address fields w/ API Get
December 14, 2013, 12:00:06 pm
is it possible the api hasn't caught up with custom fields being possible in Addresses - maybe i am behind the times but custom fields in addresses seems new-ish to me (as in i was about to say 'this isn't possible' but went and checked and it is)
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Custom address fields w/ API Get
December 14, 2013, 04:44:18 pm
Your first one was right, you just need to tell it the type of entity (it defaults to Contact)
entity_id = id & entity_table = 'civicrm_address'

Pete - custom address fields have been around for a while - where have you been?
Try asking your question on the new CiviCRM help site.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Custom address fields w/ API Get
December 14, 2013, 07:12:53 pm
me? not keeping up with everything, clearly ;-)
and you know, if you have never had need to use something (like my brain) then how would you know it was there
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Laryn

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 4
    • CEDC
  • CiviCRM version: 4.6.x
  • CMS version: Drupal 7
Re: Custom address fields w/ API Get
December 16, 2013, 10:12:47 am
Bingo! Thanks Coleman!

I added a comment on this page, as the "implicit entity_table detection" it describes under "Custom Data Retrieval Examples" doesn't work for me.

"*If implicit entity_table detection is not working, specify the entity_table to be sure. (e.g. /civicrm/ajax/rest?json=1&sequential=1&debug=1&&entity=CustomValue&action=get&entity_table=Address&entity_id=15166&return.custom_138=1"


Quote from: Coleman Watts on December 14, 2013, 04:44:18 pm
Your first one was right, you just need to tell it the type of entity (it defaults to Contact)
entity_id = id & entity_table = 'civicrm_address'

Pete - custom address fields have been around for a while - where have you been?
CEDC...social justice by design

*Get support on the new CiviCRM help site. /laryn

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Custom address fields w/ API Get

This forum was archived on 2017-11-26.