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) »
  • API: chaining using a custom contact reference field
Pages: [1]

Author Topic: API: chaining using a custom contact reference field  (Read 405 times)

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
API: chaining using a custom contact reference field
February 27, 2015, 07:33:41 am
In our implementation, we have a custom field 'organizer' (custom_56) on events, which is a contact reference. I tried to use the API to get a contact, and (using chaining) all events that have this contact as organizer.

I tried the following:

Code: [Select]
    $result = civicrm_api3('Contact', 'get', array(
    'sequential' => 1,
    'external_identifier' => "leg/0403",
    'api.Event.get' => array('custom_56_id' => "\$value.id"),
    ));

It did not work, I got all events in api.event.get. I tried with 'custom_56' (without _id) as well, it did not work either.

I know I can retrieve a contact together with all its participants, but that is not what I want. I want a contact with all the events that reference this contact in the custom field.

But I am not sure whether api chaining is supposed to work with custom fields. I couldn't find it in the documentation, maybe one of you can help me out.

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: API: chaining using a custom contact reference field
February 27, 2015, 09:07:21 am
Hmmm in theory perhaps it should....but the custom fields are a bit inconsistent in the API so for your case I would not bother with the chaining.
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
Re: API: chaining using a custom contact reference field
March 02, 2015, 01:42:41 am
I just found out that more generally searching events on custom fields using the API does not work. I guess the problem I am describing here is a special case of that problem.

I created an issue on the issue tracker: https://issues.civicrm.org/jira/browse/CRM-16036

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
Re: API: chaining using a custom contact reference field
March 10, 2015, 12:48:11 pm
The pull request for CRM-16036 fixes this problem as well.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API: chaining using a custom contact reference field

This forum was archived on 2017-11-26.