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) »
  • get address by contact_id
Pages: [1]

Author Topic: get address by contact_id  (Read 631 times)

bradut

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.2.4
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.4
get address by contact_id
February 18, 2013, 05:09:14 pm
Hello,

I am writing a wrapper to pass data from DotNetNuke (DNN) to CiviCRM by using the crm's REST API, and found out that  I cannot get an 'address' object [or a collection of addresses] by contact_id
According to CiviCRM documentation [http://wiki.civicrm.org/confluence/display/CRMDOC40/Searching+Contacts] I can query the address collection by first_name, last_name, etc... but unfortunately, not by contact_id.

I can workaround this by trying to read the address_id from a Contact object, and decide whether I need to create a new one or not, but this means I need to do an extra call to the CiviCRM API.

So, is it any way to solve my problem, or maybe I should suggest it as feature?

Thanks,
Bradut


Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: get address by contact_id
February 18, 2013, 05:40:13 pm
Have you looked at this option

http://svn.civicrm.org/civicrm/trunk/api/v3/examples/AddressGet.php
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

bradut

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.2.4
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.4
Re: get address by contact_id
February 20, 2013, 11:24:46 am
Thank you for suggesting that PHP example.
I spotted the above mentioned issue while using the "API explorer and generator"

I believe [but really not sure anymore] that things worked this way:
1. Initially:
  - there were a few reccords in the address collection, created with the CRM
  - REST queries by contact_id did not work [they worked by first_name, street_name, etc],
2. Fix:
  - I inserted a new reccord by using REST [with contact_id=null]
  - REST queries by contact_id started working

That's it.

« Last Edit: February 20, 2013, 12:08:19 pm by bradut »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • get address by contact_id

This forum was archived on 2017-11-26.