when trying to create a lead from marketto, assignment rules are working fine but when the same lead is updated assignment rules are not applied properly, for example if we have country in the assignment rules when a lead is created it is assigned the right queue, but when we update the same lead with a different coutry lead is not assigned to right queue.
Normally, Lead assignment rules are triggered upon new lead, and, from the API (i.e. Marketo), Marketo must supply an
If you want to reassign leads based on an update, then, as you know, in the UI, the user must manually tick the checkbox to apply assignment rules. The same holds true for any API client, the
AssignmentRuleHeader would have to be applied on updates.
But there are good reasons for an API client not to do this.
- New lead comes in, assigned to
- For whatever reason,
- Marketo updates the lead and reapplies the assignment rules. OOps - reassigned back to
Marketo (or any API client) doesn't really have access to the conditionals used in the assignment rules and hence can't discriminate between changes to Lead fields that might cause reassignment versus changes to lead fields that are benign and won't cause reassignment.
Hence, the API clients like Marketo play it safe and invoke Lead assignment rules only on
In your use case, you'll need to detect a field change and invoke a DML update on the lead with the
AssignmentRuleHeader set. This can be done in an APEX trigger or Apex invocable method called by Process Builder.