16

Chaining will attempt to "guess" at the id of the chained entity. In your first example, the fetched participant record has an "event_id" and the api chaining controller passes that into the chained Event api call as the id. The guessing is pretty basic though. For everything else, you should specify params explicitly. You do so by using the magic "$value" ...


7

Drush can read parameters from standard input in JSON format if you supply the argument --in=json. This is what we need for API chaining, because chaining uses nested parameters, and in contrast to a flat list of command line arguments (the default way to pass parameters to drush cvapi, JSON can handle nesting. So to retrieve the email addresses for contact ...


4

Answer (thanks to @ErikH and @Demerit): the problem was that the case type did not have an Open Case activity in its standard timeline (presumably I had deleted it). Anyway, I added the Open Case activity to the standard timeline, and subsequently-created cases have been fine.


3

I also noticed that querying the API for custom fields does not return them unless they are specified in the return fields. But the field that is listed in the API explorer in not the actual field name, I could not get the fields to return using their "title names" but they do when using the custom_xx field name.


3

I believe it would be '$value.id' (ex. https://github.com/civicrm/civicrm-core/blob/master/api/v3/examples/Contact/APIChainedArrayValuesFromSiblingFunction.php). Basically, '$value' can be used to reference any values added by the parent api call. Also, to your question about sanitization, the values should be sanitized. However, I would recommend using ...


2

You probably do not have an Open Case activity configured for your case type.


2

Pasting Adam's comment as the answer: OK, from my understanding after researching further, you can't retrieve/set custom fields via the case API - Thanks Brian! So basically I have to run multiple queries to get the data, which isn't efficient for large record sets. Hopefully one day I'll get the chance to add custom fields to standard entities on the API! ...


2

I believe there is a notation for issuing multiple chains by appending ".2", ".3", etc. For example, in api/v3/examples/Contact/ChainTwoWebsites.php, it uses: 'api.website.create' => array( 'url' => 'http://civicrm.org', ), 'api.website.create.2' => array( 'url' => 'http://chained.org', ), As far as I know, there is no way to do aliases. ...


1

I don't think that is possible. The chained API works to extend the data on the contacts found. Could you explain a little more on why and what you want to achieve functional?


1

OK, I got it! I had to think backwards: $result = civicrm_api3('ContactType', 'get', array( 'sequential' => 1, 'name' => "Organization", 'api.ContactType.create' => array('label' => "Entity", 'id' => "\$value.id"), ));


1

I don't know the answer about hidden smart groups but I took a swipe at the API chaining and was able to pull a contact on the demo server that met one criteria on the contact and another on the geocode on the address: I don't know if that is helpful at all, but if you can get the first portion of this API call working with your custom field, it seems you ...


1

You can use try/catch and the CiviCRM_API3_Exception class to get more information. It would be something like this: try{ $result = civicrm_api3('contact', 'get', $params); } catch (CiviCRM_API3_Exception $e) { // handle error here $errorMessage = $e->getMessage(); $errorCode = $e->getErrorCode(); $errorData = $e->getExtraParams(); ...


Only top voted, non community-wiki answers of a minimum length are eligible