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

Run territory assignment rules via Apex or REST API


We have configured territory management and implemented a trigger on account object to update a field based on specific conditions. This field is used as a criteria for running territory assignment rules but when the field is updated by the Apex trigger, we have noticed that the territory rules are not evaluated.

According to online documentation and forums, the territory rules are only triggered from the Salesforce interface (if the option "Run territory assignment rules on save" is enabled and visible on page layouts) or from an API call.

With the new release, is it possible to trigger territory assignment rules from Apex and how to implement it ?


If its not possible from Apex, can you please provide some sample PHP codes to run the rules via REST API ?


Hi ,

Did you get the answer for this.
I am also stuck for the same.

Let me know how you fix that ASAP

This is still an issue according to this post:

In my case, I ended up developing a trigger in salesforce that sets a boolean flag on account on certain conditions. Then there is an external SOAP api call that is executed in PHP, that updates this flag again on account while applying "useDefaultRule" option to the AssignmentRuleHeader. This header option allows the territory rules to be executed again on update of the account boolean flag
$header = new AssignmentRuleHeader(null, true);

For more information about this header attribute :

Hope this helps