function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HarmpieHarmpie 

Question about the internals of Database.convertLead

Currently I am working on an APEX implementation of converting leads in bulk. The Database.convertLead accepts a list of leads as input, but it seems to me that the conversion of let's say a list of 20 leads, causes 20 separate inserts on account. Since I have an @future call on the Account trigger, this is now breaking, as all the 20 inserts seem to happen within the same context for limits (i.e. 10 future calls), but in separate trigger instances. So regardless of the fact my trigger is handling Accounts in bulk and then passes a list to the @future call, it will still break, since the trigger is called for every separate new Account (i.e. 20 in a Database.convertLead call with 20 leads).

 

Anyone has any experience with this issue and how to deal with it?

 

 

HarmpieHarmpie

A bit closer examination shows that although the first attempt to mass Database.convertLead() (called with all-or-nothing mode turned OFF) offers all the Account in the conversion set to enter the Account trigger together, but once 1 in the set fails, it seems insert on Account is retried separately for every faillure (causing the exception). Why is this?