Answers.Body: <p>I believe there is a notation for issuing multiple chains by appending ".2", ".3", etc. For example, in <a href="https://github.com/civicrm/civicrm-core/blob/4.7.2/api/v3/examples/Contact/ChainTwoWebsites.php" rel="nofollow">api/v3/examples/Contact/ChainTwoWebsites.php</a>, it uses:</p>
  
  <pre><code>'api.website.create' =&gt; array(
    'url' =&gt; 'http://civicrm.org',
  ),
  'api.website.create.2' =&gt; array(
    'url' =&gt; 'http://chained.org',
  ),
  </code></pre>
  
  <p>As far as I know, there is no way to do aliases.</p>
  
  <p>Note: The class which handles chaining is <a href="https://github.com/civicrm/civicrm-core/blob/4.7.2/Civi/API/Subscriber/ChainSubscriber.php" rel="nofollow">ChainSubscriber</a>. 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. <code>api.Contact.getsingle.self</code>, <code>api.Contact.getsingle.manager</code>) -</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-22T18:41:54.943Z
Answers.LastActivityDate: 2016-02-22T18:41:54.943Z
Answers.UserDisplayName: Tim Otten
Body: <p>I have a query in which I need to chain <code>api.Contact.getsingle</code> twice, given that the entity I'm querying is linked to two different contacts for which I need to fetch the data.</p>
  
  <p>The problem is that, given that both chained calls have the same name, it seems that the last one overrides the first.</p>
  
  <p>Basically I need to do this:</p>
  
  <p><code>$result = civicrm_api3('MyEntity', 'get', array(
    'sequential' =&gt; 1,
    'api.Contact.getsingle' =&gt; array('id' =&gt; "\$value.contact_id"),
    'api.Contact.getsingle' =&gt; array('id' =&gt; "\$value.manager_id"),
  ));
  </code>
  but with the ability to "alias" each chained call so that they don't get overridden</p>
  
  <p>Is it possible to do it? If not, what a different approach would look like?</p>
  
  <p>Thanks!</p>
  
Tags: <api><chaining>
Title: Alias for chained API calls?
ThreadText: # Alias for chained API calls?
  
  (Asked by: username_0 on 2016-02-19)
  
  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!
  
  **Tags:** api, chaining
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-02-22. Score: 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](https://github.com/civicrm/civicrm-core/blob/4.7.2/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](https://github.com/civicrm/civicrm-core/blob/4.7.2/Civi/API/Subscriber/ChainSubscriber.php). 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`) -
  
  
  ---
  
  