Skip to content

Instantly share code, notes, and snippets.

View harrisonhoran's full-sized avatar

Harrison Horan harrisonhoran

  • 22:16 (UTC -07:00)
View GitHub Profile
@dhoechst
dhoechst / OppTerrAssignDefaultLogicFilter.class
Last active January 30, 2023 21:13
Salesforce Opportunity Territory Assignment Logic
/*** Apex version of the default logic.
* If opportunity's assigned account is assigned to
* Case 1: 0 territories in active model
* then set territory2Id = null
* Case 2: 1 territory in active model
* then set territory2Id = account's territory2Id
* Case 3: 2 or more territories in active model
* then set territory2Id = account's territory2Id that is of highest priority.
* But if multiple territories have same highest priority, then set territory2Id = null
*/