[SalesForce] How to trigger assignment rules to run for an account record or group of records

Background

I have a mobile app that is using the REST API to create new accounts in my Salesforce org. I am using territory management to assign my accounts out to my users. It looks like the assignment rules are not running when the account is created or updated via the REST API.

I have tried setting the Assignment Rule Header via the mobile sdk but this doesn't appear to be possible.

So I need to be able to trigger the assignment rules. Either whenever an account address is updated by via the REST API or on a schedule. I don't want to have to manually re-run the assignment rules.

I have considered using a trigger or Apex Class to use Database.DMLOptions to set the assignment rule header but it sounds like that only works for leads and cases and not accounts. Running Case Assignment Rules From Apex

What other options do I have?

Best Answer

Like you said, the Assignment Rule Header only works on Cases and Leads, so really your only option would be to replicate the logic of the Assignment Rule in your trigger. This doesn't allow users the same degree of flexibility with how their Accounts are assigned, but you could add a Checkbox field like Use_Custom_Assignment__c to bring some of that back. It is hard to tell if this is realistic in your use case as it really depends on how complicated the Assignment Rule is in the first place.