If I change a record owner using apex, will any assignment rules run, and change the owner as specified by the rule? I am asking because assignment rules come after triggers in execution sequence.

By default I have kept 'Assign using assignment rule' checkbox unchecked.

  • Ideally it should not change it. Maybe try it and let us know if you are facing a specific issue. – Raul Mar 13 '17 at 12:25
  • do you have any active assignment rules? – Santanu Boral Mar 13 '17 at 12:42
  • yes...I have a active assignment rule – Dnyaneshwar Mar 13 '17 at 12:56
  • But my understanding is lead assignment rule should not run for every DML in apex – Dnyaneshwar Mar 13 '17 at 12:57
  • it depends how you have handled in your configuration and apex code – Santanu Boral Mar 13 '17 at 13:02

Assignment rules run when:

  1. An API client inserts a Lead and specifies an AssignmentRuleHeader. This is typical for Marketing Automation Systems like HubSpot or Marketo.
  2. A DML statement is executed that includes DmlOptions with property AssignmentRuleHeader set.
  3. The user clicks 'assign using active assignment rules' on the OOTB Lead edit page.

These three rules tell SFDC to execute assignment rules. Just doing a DML insert without any AssignmentRuleHeader set explicitly or implicitly does not run the assignment rules.

If you are trying to coerce the ownerId in the before trigger when one of the three use cases above apply, the assignment rules will smash your coercion. A workaround (the example is for Case but principle applies as well to Lead) is here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.