This is an update to the answer given by petednz - fuzion. In my case I needed to create a view which showed a list of all employees of the organisation employing the currently logged in employee. In other words if a contact is logged into the website (Drupal), they can see the details for their organisation and all the employees of their organisation.
I followed the steps given in the answer by petednz, but this didn't work for me. I needed to adjust his section when connecting B to C to get it to work. The steps I followed were:
- Create user view
- Create relationship from user to CiviCRM contact (to create link from current Drupal user to their Civi contact details)
- Add Current User to filters (to only show information for logged in user)
- Create relationship for CiviCRM Relationship (starting from contact A)
- Create relationship: CiviCRM Relationships: Contact ID B (4 & 5 connects currently logged in user to organisation)
- Create relationship: CiviCRM Relationship (starting from Contact B)
- Create relationship: CiviCRM Relationships: Contact ID A (6 & 7 now shows all employees connected to the organisation shown in step 5)
To show fields relating to the currently logged in user use the relationship defined in step 2.
To show fields relating to the organisation, use the relationship defined in step 5.
To show fields relating to the employees of the organisation, use the relationship defined in step 7.
The difference between my answer and petednz's answer is that when he is connecting B to C, he creates the CiviCRM Relationship (starting from Contact A), and I use the CiviCRM Relationship (starting from Contact B), and then he creates the CiviCRM Relationships: Contact ID B, and I create the CiviCRM Relationships: Contact ID A.
I have created an export of my view which demonstrates the answer.
It should then be possible to create one part of the view to show the organisation details and then an attachment view to show the employees to tidy things up.