Please Login with your Salesforce ID to post, promote or comment.
Salesforce IdeaExchange
FAQs | Terms of Use8282 Ideas; Promoted 177409 Times; 17086 Comments.
- Suggest a New Product Concept
- Promote Ideas That You Want to See Developed
- Discuss With Product Managers and Other Users
- See What We Are Planning To Deliver
Clean up and document trigger behavior with batch Lead conversions.
Using the API you can convert up to 100 leads at a time, which causes some major issues with Apex triggers and governor limits. At a minimum, three separate triggers are fired for the lead, account and contact objects. However, in some situations those triggers are fired separately for every lead in the conversion batch, leading up to the possibility of 300 triggers being fired in one Apex batch. That entire batch will have a single governor limit applied to it. If you have one trigger on each object that only performs one SOQL query, you'll hit the governor limit at lead 34 out of 100 in this scenario.
In addition to the above issues, there is no way to determine if your triggers are being fired from a lead conversion unless you track which triggers have fired within your batch by using a static variable on an Apex class as the lead update trigger is fired last. Current trigger order:
1) Update/Insert Account
2) Update/Insert Contact
3) Update Lead to set the isConverted flag
It would be possible to queue your changes in static variables in an Apex class but there's also no way to tell if the current lead being converted is the last lead in the batch and since the lead update trigger can be fired multiple times.
Lastly, none of this is documented at all in the Apex language reference. The merge process has it's trigger behavior detailed completely yet there is no similar information for lead conversion.
- 10/10/2007_5:51
- rob_tompkins
- MarkEsdale
- rpr2
- laurieh
- ejw