Find your content:

Search form

You are here

Mass Lead Conversion - Programmatically or Using Data Loader


Is there a way to mass convert leads into accounts and contacts using data loader? I believe that Partner API exposes a method that we can call to mass convert leads. Is there a way in Apex (using a scheduled class for example) to do the same?

Attribution to: kadmin

Possible Suggestion/Solution #1

Yes, it's possible to mass convert leads in Apex Code. See the documentation on Database.convertLead here: Database.convertLead docs

You can convert up to 100 leads at a time and you can use it in a scheduled class or as part of a batch apex operation (or both) if you want to convert much larger sets of leads. The documentation linked above contains good sample code at the bottom of the page. However, the example is for a single lead, here's a multiple lead conversion example:

// Create some sample leads.
List<Lead> myLeads = new List<Lead>{
    new Lead( LastName = 'Last1', Company='Company1' ),
    new Lead( LastName = 'Last2', Company='Company2' )
insert myLeads;

// Get a valid lead conversion status.
LeadStatus convertStatus = [SELECT Id, MasterLabel
    FROM LeadStatus WHERE IsConverted=true LIMIT 1];

// Create a list of lead conversions, then create a leadConvert object
// and add it to the list of lead conversions to be executed.
List<Database.LeadConvert> leadConversions = new List<Database.LeadConvert>();
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId( myLeads[0].id );
lc.setConvertedStatus( convertStatus.MasterLabel );
leadConversions.add( lc );

// Create the second lead conversion and add it to the list.
lc = new database.LeadConvert();
lc.setLeadId( myLeads[1].id );
lc.setConvertedStatus( convertStatus.MasterLabel );
leadConversions.add( lc );

// Execute the conversions and check for success.
List<Database.LeadConvertResult> results = Database.convertLead( leadConversions );

Attribution to: E.J. Wilburn
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content