You need to sign in to do that
Don't have an account?
JustD
Setting the Territory on a new Opportunity created in APEX
When I create a new Opportunity in Apex I would like to set the Territory for that Opportunity using the same logic as is applied when an Opportunity is created manually in the normal user interface.
In other words: I'd like to create and insert a new Opportunity with an Account and Owner in APEX and have its territory set exactly as Salesforce does when a user create their own Opportunities according to these rules (without having write the detailed logic to emulate this myself). Is there any method/feature/ability in APEX/Salesforce to achieve this?
- If there is a single territory that both the account and the opportunity owner belong to, the opportunity is assigned to that territory.
- If more than one territory is common to both the account and the opportunity owner, the opportunity is not automatically assigned to any territory. The opportunity owner must manually assign a territory to the opportunity.
- If no territory is common to both the account and the opportunity owner, the opportunity owner cannot assign the opportunity to a territory.
Thanks
Derek
Derek