How can I convert all my leads to contacts without creating new opportunity? Can somebody give me some example?

Thanks in advance.


Since you've tagged this as , I'll give you an answer that reflects that intent.

global class ConvertAllLeads implements Database.Batchable<SObject> {
    global Database.QueryLocator start(Database.BatchableContext context) {
        return Database.getQueryLocator([SELECT Id FROM Lead WHERE IsConverted = FALSE]);
    global void execute(Database.BatchableContext context, Lead[] scope) {
        Database.LeadConvert[] converts = new Database.LeadConvert[0];
        String convertedStatus = [SELECT MasterLabel FROM LeadStatus WHERE IsConverted = TRUE LIMIT 1].MasterLabel;
        for(Lead record: scope) {
            Database.LeadConvert lc = new Database.LeadConvert();
        Database.convertLead(converts, false);
    global void finish(Database.BatchableContext context) {


You may need to adjust the batch size if you get governor limit errors while executing this code. Also, this code ignores errors, so you'll need to check the results after processing.


To convert your leads manually, just push the convert button in Leads and untick the 'create opportunity' box.

To batch 'convert' leads to contacts, export your leads with dataloader or the export utility in datamanagement, and import them back into the Contacts object through import wizard or dataloader. Optionally, import the leads back into the Leads object with dataloader with status converted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.