I read about API chaining and I'm using it with get actions to learn more about how it works. I'm confused by the inconsistent behavior of the following two API calls:

CRM.api3('participant', 'get', 
  {"id": 12345, "api.Event.get": {} });

That gets a participant record and embeds the single associated event record within the results. Cool.

But this one works differently:

CRM.api3('participant', 'get', 
  {"id": 12345, "api.ParticipantStatusType.get": {} });

It gets the same participant record, but embeds all status type records within the results. Why?

In general, I'd like to understand what logic CiviCRM is using to filter the results of chained calls.

  • In your first example, did you mean to day "associated event record" instead of "associated contact record?"
    – Coleman
    Commented Mar 28, 2017 at 22:21
  • Yes, thank you @Coleman I did. I've edited my question to fix this typo
    – Sean
    Commented Mar 29, 2017 at 0:32

1 Answer 1


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" notation. E.g.

CRM.api3('participant', 'get', {
  id: 12345,
  "api.ParticipantStatusType.get": {id: '$value.status_id'}

Note that you can also use joins for this type of thing, which is generally more efficient than chaining. Check out joins in the Api explorer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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