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) »
  • How to use API Sibling syntax
Pages: [1]

Author Topic: How to use API Sibling syntax  (Read 335 times)

ayduns

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 6
    • Squiffle Consulting
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7
How to use API Sibling syntax
February 05, 2015, 07:16:22 am
I'm trying to use API chaining but not figuring out the sibling syntax.  The example https://github.com/civicrm/civicrm-core/blob/master/api/v3/examples/Contact/APIChainedArrayValuesFromSiblingFunction.php shows this but it's not clear (at least to me!) how to specify which value from the first call is used in the second call.

Specifically, I'm looking for households with their Head of Household relationship(s) and the related contact records.

Code: [Select]
$result = civicrm_api3('Contact', 'get', array(
  'sequential' => 1,
  'contact_type' => "Household",
  'api.Relationship.get' => array('contact_id_b' => "\$value.id", 'relationship_type_id' => "7"),
  'api.Contact.get' => array('id' => "XXX"),
));

What should XXX be to specify that it should use 'contact_id_a' from the previous api.Relationship.get call?  I tried "$value.api.Relationship.get.contact_id_a" but that returns many contacts (effectively 'id'=>"")

ayduns

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 6
    • Squiffle Consulting
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7
Re: How to use API Sibling syntax
February 25, 2015, 10:34:39 am
Just a gentle bump :-)

Is the API sibling chaining intended to do what I described?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • How to use API Sibling syntax

This forum was archived on 2017-11-26.