Answers.Body: <p>When you add Contact 3, select the entry 'Contact Related Contacts' that is indented under 'Contact Related Contacts' so that the relationship is to Contact 2 not Contact 1.</p>
  <p>If you filter by 'related' you can see the options more clearly:</p>
  <p><a href="https://i.sstatic.net/fq2cf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fq2cf.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-08T11:45:53.973Z
Answers.Text: I have no indented option there. Maybe I just need a newer version?
Answers.UserDisplayName: RebeccaTregenna
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-08T12:10:12.647Z
Answers.Text: The screenshot was from dmaster currently on 5.54.alpha1 but that feature has been around for a while.
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-08T15:36:29.357Z
Answers.Text: The normal indentation is 20px but with Shoreditch theme, it's reduced to 10px. On my big screen, I barely see it.
Answers.UserDisplayName: samuelsov
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-13T06:32:42.957Z
Answers.Text: I thought I should be able to follow the above but missing something. goal is to have who ever views this to see "the local group they manage" and therefore "all the contacts related to their local group". It sounds like your answer got Rebecca what she needed but something does not make sense to me
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-13T06:34:04.173Z
Answers.Text: and even if i did, would i then be able to 'add them to an event' or am i better fixing up drupal 9 VBO do this this via Views?
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-13T07:02:30.747Z
Answers.Text: hmm. ok i did have the SK built as required (was testing as wrong user), but no options to 'add contacts to event' that i can see. perhaps these Actions are yet to come?
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-08T11:36:45.477Z
Answers.LastActivityDate: 2022-09-08T11:36:45.477Z
Answers.UserDisplayName: Aidan
Body: <p>Hoping for some Search Kit advice / guidance.</p>
  <p>I have a search that brings in various contacts as outlined below:</p>
  <ul>
  <li>Contact 1 (Individual) - the volunteer - has associated custom data
  and a relationship to</li>
  <li>Contact 2 (Organisation) - has a relationship to</li>
  <li>Contact 3 (Service Manager)</li>
  </ul>
  <p>I can bring in the first two without issues but don't seem to bring in the 3 contact when I start with the individual as contact 1 (as no relationship to 3 I suspect).</p>
  <p>However if I flip it and start with above contact 2 (the organisation) I am able to bring in all the contacts necessary and filter contact 3 to current user only - however, I need to display custom data associated with contact 1 which I can't do when I start the search with contact 2 as the main contact.</p>
  <p>Is there a Search Kit guru that can help as I could just miss something obvious, added the SQL for my queries below.</p>
  <p><strong>Unable to bring in the service manager (to filter)</strong></p>
  <pre><code>SELECT `a`.`id` AS `id`, `a`.`display_name` AS `display_name`, `Volunteer__1`.`type_of_volunteer_64` AS `Volunteer_.Type_of_volunteer:label`, `Volunteer__1`.`vol_start_date_128` AS `Volunteer_.Vol_Start_Date`, GROUP_CONCAT(DISTINCT `far_contact_id_2`.`display_name` SEPARATOR &quot;&quot;) AS `GROUP_CONCAT_Contact_RelationshipCache_near_contact_id_01_far_contact_id_display_name`, GROUP_CONCAT(DISTINCT `near_contact_id_3`.`display_name` SEPARATOR &quot;&quot;) AS `GROUP_CONCAT_Contact_RelationshipCache_far_contact_id_01_near_contact_id_display_name`
  FROM civicrm_contact a
  INNER JOIN `civicrm_relationship_cache` `Contact_RelationshipCache_near_contact_id_01` ON `a`.`id` = `Contact_RelationshipCache_near_contact_id_01`.`near_contact_id` AND `Contact_RelationshipCache_near_contact_id_01`.`near_relation` = &quot;Volunteer of&quot;
  INNER JOIN `civicrm_relationship_cache` `Contact_RelationshipCache_far_contact_id_01` ON `a`.`id` = `Contact_RelationshipCache_far_contact_id_01`.`far_contact_id` AND `Contact_RelationshipCache_far_contact_id_01`.`near_relation` = &quot;Service Manager for&quot;
  LEFT JOIN `civicrm_value_volunteer__15` `Volunteer__1` ON `a`.`id` =  `Volunteer__1`.`entity_id`
  LEFT JOIN `civicrm_contact` `far_contact_id_2` ON `Contact_RelationshipCache_near_contact_id_01`.`far_contact_id` =  `far_contact_id_2`.`id`
  LEFT JOIN `civicrm_contact` `near_contact_id_3` ON `Contact_RelationshipCache_far_contact_id_01`.`near_contact_id` =  `near_contact_id_3`.`id`
  WHERE (`a`.`is_deleted` = &quot;0&quot;)
  GROUP BY `a`.`id`
  ORDER BY `a`.`sort_name` ASC
  LIMIT 50
  OFFSET 0
  </code></pre>
  <p><strong>Able to filter</strong></p>
  <pre><code>SELECT `a`.`id` AS `id`, `a`.`display_name` AS `display_name`, `near_contact_id_1`.`display_name` AS `Contact_RelationshipCache_near_contact_id_01.near_contact_id.display_name`, `far_contact_id_2`.`display_name` AS `Contact_RelationshipCache_near_contact_id_01.far_contact_id.display_name`, `far_contact_id_3`.`display_name` AS `Contact_RelationshipCache_near_contact_id_02.far_contact_id.display_name`, `Contact_RelationshipCache_near_contact_id_01`.`near_contact_id` AS `Contact_RelationshipCache_near_contact_id_01.near_contact_id`, `Contact_RelationshipCache_near_contact_id_01`.`relationship_id` AS `Contact_RelationshipCache_near_contact_id_01.relationship_id`, `Contact_RelationshipCache_near_contact_id_01`.`orientation` AS `Contact_RelationshipCache_near_contact_id_01.orientation`, `Contact_RelationshipCache_near_contact_id_02`.`near_contact_id` AS `Contact_RelationshipCache_near_contact_id_02.near_contact_id`, `Contact_RelationshipCache_near_contact_id_02`.`relationship_id` AS `Contact_RelationshipCache_near_contact_id_02.relationship_id`, `Contact_RelationshipCache_near_contact_id_02`.`orientation` AS `Contact_RelationshipCache_near_contact_id_02.orientation`
  FROM civicrm_contact a
  INNER JOIN `civicrm_relationship_cache` `Contact_RelationshipCache_near_contact_id_01` ON `a`.`id` = `Contact_RelationshipCache_near_contact_id_01`.`near_contact_id` AND `Contact_RelationshipCache_near_contact_id_01`.`near_relation` = &quot;Service Manager is&quot; AND `Contact_RelationshipCache_near_contact_id_01`.`far_contact_id` = &quot;39260&quot;
  LEFT JOIN `civicrm_relationship_cache` `Contact_RelationshipCache_near_contact_id_02` ON `a`.`id` = `Contact_RelationshipCache_near_contact_id_02`.`near_contact_id` AND `Contact_RelationshipCache_near_contact_id_02`.`near_relation` = &quot;Volunteer is&quot;
  LEFT JOIN `civicrm_contact` `near_contact_id_1` ON `Contact_RelationshipCache_near_contact_id_01`.`near_contact_id` =  `near_contact_id_1`.`id`
  LEFT JOIN `civicrm_contact` `far_contact_id_2` ON `Contact_RelationshipCache_near_contact_id_01`.`far_contact_id` =  `far_contact_id_2`.`id`
  LEFT JOIN `civicrm_contact` `far_contact_id_3` ON `Contact_RelationshipCache_near_contact_id_02`.`far_contact_id` =  `far_contact_id_3`.`id`
  WHERE (`a`.`is_deleted` = &quot;0&quot;)
  ORDER BY `a`.`sort_name` ASC
  LIMIT 50
  OFFSET 0
  </code></pre>
  <p>As per Aidan's answer below - achievable with a later version of CiviCRM (I was on 5.49)</p>
  
Tags: <searchkit>
Title: Search Kit - related contacts query
ThreadText: # Search Kit - related contacts query
  
  (Asked by: username_0 on 2022-09-08)
  
  Hoping for some Search Kit advice / guidance.
  I have a search that brings in various contacts as outlined below:
  
  Contact 1 (Individual) - the volunteer - has associated custom data
  and a relationship to
  Contact 2 (Organisation) - has a relationship to
  Contact 3 (Service Manager)
  
  I can bring in the first two without issues but don't seem to bring in the 3 contact when I start with the individual as contact 1 (as no relationship to 3 I suspect).
  However if I flip it and start with above contact 2 (the organisation) I am able to bring in all the contacts necessary and filter contact 3 to current user only - however, I need to display custom data associated with contact 1 which I can't do when I start the search with contact 2 as the main contact.
  Is there a Search Kit guru that can help as I could just miss something obvious, added the SQL for my queries below.
  Unable to bring in the service manager (to filter)
  SELECT `a`.`id` AS `id`, `a`.`display_name` AS `display_name`, `Volunteer__1`.`type_of_volunteer_64` AS `Volunteer_.Type_of_volunteer:label`, `Volunteer__1`.`vol_start_date_128` AS `Volunteer_.Vol_Start_Date`, GROUP_CONCAT(DISTINCT `far_contact_id_2`.`display_name` SEPARATOR "") AS `GROUP_CONCAT_Contact_RelationshipCache_near_contact_id_01_far_contact_id_display_name`, GROUP_CONCAT(DISTINCT `near_contact_id_3`.`display_name` SEPARATOR "") AS `GROUP_CONCAT_Contact_RelationshipCache_far_contact_id_01_near_contact_id_display_name`
  FROM civicrm_contact a
  INNER JOIN `civicrm_relationship_cache` `Contact_RelationshipCache_near_contact_id_01` ON `a`.`id` = `Contact_RelationshipCache_near_contact_id_01`.`near_contact_id` AND `Contact_RelationshipCache_near_contact_id_01`.`near_relation` = "Volunteer of"
  INNER JOIN `civicrm_relationship_cache` `Contact_RelationshipCache_far_contact_id_01` ON `a`.`id` = `Contact_RelationshipCache_far_contact_id_01`.`far_contact_id` AND `Contact_RelationshipCache_far_contact_id_01`.`near_relation` = "Service Manager for"
  LEFT JOIN `civicrm_value_volunteer__15` `Volunteer__1` ON `a`.`id` =  `Volunteer__1`.`entity_id`
  LEFT JOIN `civicrm_contact` `far_contact_id_2` ON `Contact_RelationshipCache_near_contact_id_01`.`far_contact_id` =  `far_contact_id_2`.`id`
  LEFT JOIN `civicrm_contact` `near_contact_id_3` ON `Contact_RelationshipCache_far_contact_id_01`.`near_contact_id` =  `near_contact_id_3`.`id`
  WHERE (`a`.`is_deleted` = "0")
  GROUP BY `a`.`id`
  ORDER BY `a`.`sort_name` ASC
  LIMIT 50
  OFFSET 0
  
  Able to filter
  SELECT `a`.`id` AS `id`, `a`.`display_name` AS `display_name`, `near_contact_id_1`.`display_name` AS `Contact_RelationshipCache_near_contact_id_01.near_contact_id.display_name`, `far_contact_id_2`.`display_name` AS `Contact_RelationshipCache_near_contact_id_01.far_contact_id.display_name`, `far_contact_id_3`.`display_name` AS `Contact_RelationshipCache_near_contact_id_02.far_contact_id.display_name`, `Contact_RelationshipCache_near_contact_id_01`.`near_contact_id` AS `Contact_RelationshipCache_near_contact_id_01.near_contact_id`, `Contact_RelationshipCache_near_contact_id_01`.`relationship_id` AS `Contact_RelationshipCache_near_contact_id_01.relationship_id`, `Contact_RelationshipCache_near_contact_id_01`.`orientation` AS `Contact_RelationshipCache_near_contact_id_01.orientation`, `Contact_RelationshipCache_near_contact_id_02`.`near_contact_id` AS `Contact_RelationshipCache_near_contact_id_02.near_contact_id`, `Contact_RelationshipCache_near_contact_id_02`.`relationship_id` AS `Contact_RelationshipCache_near_contact_id_02.relationship_id`, `Contact_RelationshipCache_near_contact_id_02`.`orientation` AS `Contact_RelationshipCache_near_contact_id_02.orientation`
  FROM civicrm_contact a
  INNER JOIN `civicrm_relationship_cache` `Contact_RelationshipCache_near_contact_id_01` ON `a`.`id` = `Contact_RelationshipCache_near_contact_id_01`.`near_contact_id` AND `Contact_RelationshipCache_near_contact_id_01`.`near_relation` = "Service Manager is" AND `Contact_RelationshipCache_near_contact_id_01`.`far_contact_id` = "39260"
  LEFT JOIN `civicrm_relationship_cache` `Contact_RelationshipCache_near_contact_id_02` ON `a`.`id` = `Contact_RelationshipCache_near_contact_id_02`.`near_contact_id` AND `Contact_RelationshipCache_near_contact_id_02`.`near_relation` = "Volunteer is"
  LEFT JOIN `civicrm_contact` `near_contact_id_1` ON `Contact_RelationshipCache_near_contact_id_01`.`near_contact_id` =  `near_contact_id_1`.`id`
  LEFT JOIN `civicrm_contact` `far_contact_id_2` ON `Contact_RelationshipCache_near_contact_id_01`.`far_contact_id` =  `far_contact_id_2`.`id`
  LEFT JOIN `civicrm_contact` `far_contact_id_3` ON `Contact_RelationshipCache_near_contact_id_02`.`far_contact_id` =  `far_contact_id_3`.`id`
  WHERE (`a`.`is_deleted` = "0")
  ORDER BY `a`.`sort_name` ASC
  LIMIT 50
  OFFSET 0
  
  As per username_1's answer below - achievable with a later version of CiviCRM (I was on 5.49)
  
  **Tags:** searchkit
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-09-08. Score: 3 | Accepted answer
  
  When you add Contact 3, select the entry 'Contact Related Contacts' that is indented under 'Contact Related Contacts' so that the relationship is to Contact 2 not Contact 1.
  
  If you filter by 'related' you can see the options more clearly:
  
  [![enter image description here](https://i.sstatic.net/fq2cf.png)](https://i.sstatic.net/fq2cf.png)
  
  > **Comments:**
  > **username_0**: I have no indented option there. Maybe I just need a newer version?  
  > **username_1**: The screenshot was from dmaster currently on 5.54.alpha1 but that feature has been around for a while.  
  > **username_2**: The normal indentation is 20px but with Shoreditch theme, it's reduced to 10px. On my big screen, I barely see it.  
  > **username_3**: I thought I should be able to follow the above but missing something. goal is to have who ever views this to see "the local group they manage" and therefore "all the contacts related to their local group". It sounds like your answer got Rebecca what she needed but something does not make sense to me  
  > **username_3**: and even if i did, would i then be able to 'add them to an event' or am i better fixing up drupal 9 VBO do this this via Views?  
  > **username_3**: hmm. ok i did have the SK built as required (was testing as wrong user), but no options to 'add contacts to event' that i can see. perhaps these Actions are yet to come?  
  
  ---
  
  