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
Rodolfo Calvo 3Rodolfo Calvo 3 

How to convert all my Leads to Contacts

Hello team, 

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

Thanks in advance. 
Best Answer chosen by Rodolfo Calvo 3
Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri
Hey, use this

classname.convertLead('00Q9000000vmN7R'); // use your leadID tha you want to convert.

All Answers

Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri
public class LeadConvertWithoutOpportunity{
    public static void convertLead(Id leadId){

        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(leadId);
        lc.setDoNotCreateOpportunity(True); // Use this so that you can avoid creating opportunity

        LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
        lc.setConvertedStatus(convertStatus.MasterLabel);
        Database.LeadConvertResult lcr = Database.convertLead(lc);
    }
}
Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri
Let me know if anything else needed
Rodolfo Calvo 3Rodolfo Calvo 3
At executing this code: 
 
LeadCtrl ln = new LeadCtrl();
ln.convertLead(Id leadId);

an erros is shown: 
 
Line: 2, Column: 18
expecting a right parentheses, found 'leadId'

What's wrong? 
Thanks in advance. 
Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri
Hey, use this

classname.convertLead('00Q9000000vmN7R'); // use your leadID tha you want to convert.
This was selected as the best answer
Rodolfo Calvo 3Rodolfo Calvo 3
Thanks a lot!!