function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Travis16Travis16 

Query Orders based on Logged in user across multiple accounts

So within our community we have a query that finds the logged in users information and we use that to query the orders (custom orders object) on the account to show on our orders page. An issue has been brought up that the contact could be on another accounts and the business wants all the orders to show. 

So here are the options and questions about each option I have. 
User ContactRoles on the accounts to link the single contact to mulitple accounts. 
1. Can I query based off contact roles over all the accounts to pull back orders. (I feel like this might cause issues with the amount of data)

Change the business process and have 1 accounts here all contacts live and there is not duplication. I wouldn't need to change anything here as all the orders will be based on the contacts accounts. (I feel like this is the best option for a cleaner database)
1. Any advice on how to speak to this with higher ups so they understand. 

Use Parent account relationship and change the query so it is based off the master parent account and queries all child accounts to show the orders. 
1. Is there any way to tell if the account is a master account (the highest in the hierarchy)?
2. Would I be able to split these orders up on my visual force page dynamicly based off location of the account? (I have no Idea how this is possible with all the variastions there might be)

Thanks in advance