[SalesForce] Trigger Lead Owner assignment not working for Web to Lead Form records

HI Folks,

Got into some interesting scenario, Need your suggeestion to
understand this issue.

Below is the Order of Execution for Lead owner assignment that we
have

Scenario : Mode of Lead creation in the system is through Web-to-Lead
form

1) Trigger (Before Insert):- This trigger based on some logic assigns
lead to an one of the existing user only if the Logic meets the
business requirement

1) Lead Assignment Rule :- If Lead owner is not assigned in above
trigger then Assignment rules does the owner assignment based on some
criteria

ISSUE :

Trigger is not able to assign the owner though it finds the mataches and does not even throw the error. This happens only for
those leads which are getting created through web to lead form.

Some one suggested me to create an one more Rule Entry to existing Assignment Rule , with empty criteria and Do Not Reassign
Owner checkbox checked. Which i did and Trigger started working.

I still dint understand the use of this check box and how it is related to it.

Best Answer

Assignment rules always fire for web-to-lead, and the assignment occurs after the initial database commit, so the owner field would be clobbered by the assignment rule. Furthermore, if the rule fails to find an owner, the default lead owner is used instead. So, in order to prevent the rule from changing the owner, there must be an entry that uses the "do not reassign owner" checkbox. This prevents the default lead owner from taking over the record.

Related Topic