Territory Management: running territory assignment rules on Account edit
|Knowledge Article Number||000004725|
The administrator of an org with Territory Management enabled wants territory assignment rules to run when Accounts are edited.
There is a checkbox that can be added to the Account page layout called "Evaluate this account against territory rules on save". To add this checkbox to the page layout, perform the following steps:
1. Setup -> Customize -> Accounts -> Page Layouts
2. Click Edit next to the page layout
3. Click the Layout Properties button at the top of the page
4. Check the "Show on edit page" checkbox next to "Evaluate this account against territory rules on save"
5. Optionally check the "Select by default" checkbox to auto-check the checkbox on the page layout
6. Click OK then save the page layout
Territory assignment rules are run automatically when users check the “Select by default” checkbox but not the “Show on edit page”. If both checkboxes are checked, the “Evaluate this account against territory rules on save” checkbox will be displayed on the edit page and checked by default, and territory assignment rules will be run on edit. However, the user can uncheck the “Evaluate this account against territory rules on save” checkbox on the edit page, and territory assignment rules will not be run.
As of version 21 of the Force.com Apex Code Developer's Guide, there is not a way to run territory assignment rules through Apex: "assignmentRuleHeader method - The database.DMLOptions object supports assignment rules for cases and leads, but not for accounts or territory management."
The only option as of API version 21 is to use the Web Services API. See AssignmentRuleHeader in the Web Services API Developer Guide for more information:
"AssignmentRuleHeader – useDefaultRule - If true for a Case or Lead, uses the default (active) assignment rule for a Case or Lead. If specified, do not specify an assignmentRuleId. If true for an Account, all territory assignment rules are applied, and if false, no territory assignment rules are applied."