Good afternoon all! I appreciate any help you all can offer. I will try to articulate my dilemma as best as I can!
I have two entities: Account and Plan. The Account has a field Relationship Type that can be Client, Prospect, or Service Provider. The Plan has two fields: Recordkeeper and TPA, both of which are lookups to Accounts with a Relationship Type of Service Provider. On the Account page, I have a subgrid to show related Plans.
For any Account that is a Relationship Type of Client or Prospect, the subgrid finds all plans belonging to it. However, for an Account that is a Relationship Type of Service Provider, no plans show up (not surprising). To overcome this, I wrote a Javascript method to pass a custom fetchXml on Account load that modifies the results in the plans subgrid depending on what the Relationship Field value is. The problem I ran into is that the "See related records" button just above the subgrid does not mirror the custom fetchXml - this is due to the fact that the subgrid has to be set to show all records rather than related records in order for the custom fetchXml to filter the records appropriately. I have not found a way to be able to pass this same fetchXml to the related view that opens when you click the "See related records" button. If you know of a way to do this, this would be one solution to my situation.
Barring a solution in the prior method, my next thought is to create two plan subgrids that show only related records, and then use Javascript to hide the irrelevant subgrid on form load. As there are 1:N entity relationships, I can get everything working by using the correct relationship, and the "related records view" works! The issue that I have is that for an Account with a Relationship Type of Service Provider, I would need two subgrids to show all plans managed, one for the Plans where they are the Recordkeeper, and one for Plans where they are the TPA. The hope is that on an Account with the Relationship Type of Service Provider, one subgrid will show all Plans that they are either the Recordkeeper or TPA, all while maintaining the "see related records" button found just above the subgrid.
If you all have any ideas on how to solve this issue, I would be so grateful. If both of my approaches above are wrong, I am certainly willing to try another approach. Thank you all again for taking the time to read this and offer your advice!