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
hijinxhijinx 

rolling up opportunities by team or region

I'm looking for the simplest way to get information regarding closed opportunities for everyone in a given person's team or geographical territory.  This seems like it would be a very common thing to want to do in SF, but I can't seem to find a "best practice" for doing so.

How do I find access to all of the opportunities assigned to the same geographical location as me, or by anyone who reports to me.  These are two separate views of data I want to chart using the AJAX api to chart using Google Charts. 

Any pointers to existing documentation or code samples would be greatly appreciated.  I want to do this in the AJAX api using SOQL queries, but I'm not sure of the best way to start.  Any pointers out there?


Greg HGreg H
I had a similar requirement for a client and the solution we ended up with involved creating a custom object linking users to zip code based territories. We then used these relationships (zip assignment to User) to determine which opportunities to pull back in our sControls. This got us through the territory linkages when we needed that "view" of the opportunity figures but we ended up having to traverse the role hierarchy to determine opportunity figures based on roll up. By traversing the role hierarchy we could determine which users rolled up to a specific user and then we would query for opportunities owned by the resulting list of users.
-greg