My objective is to get a list of
AccountShare records related to groups where a specific user is in.
How would I write this query?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
If you have access to
Apex, you can do it with two queries. I don't believe it can be reduced to one:
List<Group> relatedGroups = [ SELECT Id FROM Group WHERE Id IN ( SELECT GroupId FROM GroupMembmer WHERE UserOrGroupId = :userId ) ]; List<AccountShare> shares = [ SELECT AccountId FROM AccountShare WHERE UserOrGroupId IN :relatedGroups ]