You need to sign in to do that
Don't have an account?

get accounts by territory for specific user
I've been reviewing the territory management ERD and trying to get a handle on how to query for the accounts by territory assigned to a specific user.
In my controller, I'm using UserInfo.getUserId() to get the userId of the current user.
I need to get a list of accounts filtered by territory for that user.
Looking at the ERD, it looks like I need to to query the group table, but the Ids on the group table don't have any matches to the userId, so how do I get the relevant group ids for the specific user? How do I obtain a set of ids for a specific user that can be used to query on the accountShare table that should then return a list of accounts ids that are the accounts by territory for that user?
Am I travesing the objects correctly? I'm missing a relationship somewhere.
Thanks for any help.