Answers.Body: <p>This seems to work, using a join:</p>
  
  <p><code>
      $result = civicrm_api3('Relationship', 'get', [
        'sequential' =&gt; 1,
        'return' =&gt; ["contact_id_b"],
        'relationship_type_id' =&gt; 5,
        'contact_id_a' =&gt; "user_contact_id",
        'is_active' =&gt; 1,
        'contact_id_b.is_deleted' =&gt; 0,
      ]);
  </code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-19T17:56:28.910Z
Answers.LastActivityDate: 2019-05-19T17:56:28.910Z
Answers.UserDisplayName: Demerit
Body: <p>I'm doing this call</p>
  
  <pre><code>$result = civicrm_api3('Relationship', 'getvalue', [
    'return' =&gt; "contact_id_b",
    'relationship_type_id' =&gt; 5,
    'contact_id_a' =&gt; "user_contact_id",
    'is_active' =&gt; 1,
  ]);
  </code></pre>
  
  <p>It is returning contact B from contacts that are in trash.</p>
  
  <p>I want to filter for contacts that are not in trash but struggling to find a way of doing it.</p>
  
Tags: <api>
Title: Getting active relationships using the API is returning contacts in trash
ThreadText: # Getting active relationships using the API is returning contacts in trash
  
  (Asked by: username_0 on 2019-05-19)
  
  I'm doing this call
  $result = civicrm_api3('Relationship', 'getvalue', [
    'return' => "contact_id_b",
    'relationship_type_id' => 5,
    'contact_id_a' => "user_contact_id",
    'is_active' => 1,
  ]);
  
  It is returning contact B from contacts that are in trash.
  I want to filter for contacts that are not in trash but struggling to find a way of doing it.
  
  **Tags:** api
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-05-19. Score: 4 | Accepted answer
  
  This seems to work, using a join:
  
  `$result = civicrm_api3('Relationship', 'get', [
  'sequential' => 1,
  'return' => ["contact_id_b"],
  'relationship_type_id' => 5,
  'contact_id_a' => "user_contact_id",
  'is_active' => 1,
  'contact_id_b.is_deleted' => 0,
  ]);`
  
  
  ---
  
  