In my previous post I outlined a solution to overcome a well known salesforce.com limitation around lead converion & validation rules. In this post I will briefly explain why & how the solution works.
The formula field aspect of the solution is straightforward and is self documenting.
When it comes to lead conversion remember the following concepts; the general execution order on the force.com platform and how it relates to lead conversion.
The exact details of the execution order can be found here but in general the order goes as below:
- System Validation rules (required field, field format)
- Before Triggers
- Custom Validation rules
- After Triggers
- Assignment Rules
- Auto-Response Rules
- Workflow Rules
- Before and After Triggers are executed one more time if the workflow rule updates a field
- Escalation Rules
- Parent Rollup Summary Formula or Cross Object Formula fields are updated in the respective objects. (Which in turn go through the execution order)
- Criteria Based Sharing rules are evaluated
- Any Post-Commit Logic is executed e.g. sending email
Whilst not documented, form what I have been able to test and verify and corroborated by this question on stackexchange is that for lead conversion the sequence seems to be:
Now that we understand the execution order, the solution is straight-forward and easy to understand. We have a flag on lead, field is mapped to a custom field on Account, validation rules on Account run and don’t fire based on condition….Lead is converted. Once the Account has been created workflow runs on Account and updates the flag so that validation rule is enforced for subsequent edits.