Run Account Territory rules (ETM) fom Apex

11:48 AM

 Enterprise Territory Management (ETM) rules on Account are run automatically when creation of an Account. However, they do not run automatically on account update. Out of the box, here are some options available.

Include the checkbox on the layout

                                
 
Run the ETM rules from settings, setup -> territory models -> pick a territory and run all rules assigned to the territory
  
 
Here are some limitations with running ETM rules automatically
  • ETM rules do not run on inline edit
  • DML updates from Apex do not run ETM rules

To programmatically run ETM rules on every account update, you could fire off a REST callout to update the account. This will run the ETM rules. Here is a sample code that uses Queueable job to perform this.

Make sure to pass the accountId and any other fields you would like to include in the dataWrapperJson variable.




0 comments