I couldn't test all the way with Entityref Views, I seem to have a bug in choosing Views on my Field settings. But I was able to create the Views and it works as expected in Views preview.
The goal is to create Views of sibling nodes. In your case we need to list Person nodes that are sibling nodes to the Service node you're currently viewing. They are sibling through the Agency Entity reference field (they both refer to the same Agency node).
When both References to Agency are the same field
This is the case when the references to Agency from both Service and Person are the same field, reused (this happens when you create one ref field on one content type, then on the other content type you choose from the second drop-down "Re-use an existing field").
- Create Content Views showing Person. You don't need Page nor Block, add Entity reference Display.
- Show Fields Title and Agency (to test filtering works as expected, you can remove Agency later)
- Under "Entity Reference inline fields" set Separator to
from (with spaces on each side) so you get meaningful output Person: Name1 from Agency: Agency1
- Add a Relationship Content referenced from field_agency, you can require it. This is the Agency a Person listed in Views is referring to.
- Add another Relationship Content using field_agency, set it to use the Relationship from the previous step, you can require it. This is the reverse direction, pointing to all content that is pointing to this Agency.
- Add a Contextual Filter ID from Content Category and set it to use the second relationship (field_agency) and configure:
When the filter value is NOT available
Provide default value
Content ID from URL
When the filter value IS available or a default is provided
Specify validation criteria
- Configure Entity ref field settings to use this View, and choose the widget on "Manage form display".
That's it! You can test Views through Preview by entering one of the Service NIDs. Don't forget to add some "No results" text.
The Views will list only Person that are in Agency that this Service is referring to.
When References to Agency are NOT the same field
This case is when you created two different Entity reference fields on Service and Person (they have different machine names). Configuration is a bit different even though they refer to the same Agency.
You create Views the same as above only with these differences:
- The first Relationship needs to be of the Entity reference to Agency that is on the Person CT.
The second Relationship needs to be of the Entity reference to Agency that is on the Service CT.
Again this second Relationship must use the Relationship from the previous step. This is where the magic happens, where Service and Person Agency fields are compared.
The Contextual ID Filter needs to be using the second Relationship, as in the first case. This Contextual is only passing on the Service ID of the page you're on to Views.