2

I have a query in which I need to chain api.Contact.getsingle twice, given that the entity I'm querying is linked to two different contacts for which I need to fetch the data.

The problem is that, given that both chained calls have the same name, it seems that the last one overrides the first.

Basically I need to do this:

$result = civicrm_api3('MyEntity', 'get', array( 'sequential' => 1, 'api.Contact.getsingle' => array('id' => "\$value.contact_id"), 'api.Contact.getsingle' => array('id' => "\$value.manager_id"), )); but with the ability to "alias" each chained call so that they don't get overridden

Is it possible to do it? If not, what a different approach would look like?

Thanks!

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.

Note: The class which handles chaining is ChainSubscriber. In skimming that code, I don't see anything which explicitly processes the ".2" suffix as a number. It would be worth a try to use a prettier/symbolic suffix (e.g. api.Contact.getsingle.self, api.Contact.getsingle.manager) -

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.