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
ryan_mmryan_mm 

Identifying which Territory an Opportunity is in

Hi,

Our product uses the API to query data from SF. We're trying to build a feature into our product that deals with opportunities and territory management. We got territory management enabled for one of our developer orgs. We then found it straight-forward to get the master list of territories and their hierarchy by querying for the Id, Name, and ParentTerritoryId from the Territory table. The issue we're having is it's unclear to us how to figure out which territory an opportunity (or associated account) is in.

The documentation (from link below) says that there should be a TerritoryId field on the Opportunity object but this doesn't seem to be the case. That field doesn't exist. How can we figure out which territory an opportunity is in?

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_erd_territory.htm

One of our guys posted a similar question in another thread here (link below) but we weren't really clear on the response. Going through several of these "sharing" tables seemed like an overly complex approach. Isn't there just a TerritoryId field on the Opportunity object?

http://community.salesforce.com/sforce/board/message?board.id=apex&thread.id=1996

Ryan