All Ideas

Idea Details

Post an Idea
80  Points
Open
Idea has been posted. Give it an upvote or downvote.

Clean up and document trigger behavior with batch Lead conversions.

Accounts & Contacts

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.

Merge Idea · Flag

  • Upvotes
  • Downvotes

Ideas

Apps

from AppExchange

Questions

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



 

 

Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


 

Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.