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
Sarma DuvvuriSarma Duvvuri 

Apex Class for Lead Conversion to the existing Account


I am not able to update the contact details for existing account in Lead Conversion. Kindly help in this issue.

This is the code i am using.

Public class AutoConvertLeads
    public static void LeadAssign(List<Id> LeadIds)
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(id currentlead: LeadIds){
                Database.LeadConvert Leadconvert = new Database.LeadConvert();
                Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to create an opportunity from Lead Conversion 
        if (!MassLeadconvert.isEmpty()) {
            List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);
Vinod ChoudharyVinod Choudhary
Hi Sarma,

Hope this will help you.

Colin KenworthyColin Kenworthy
Starting API v36.0 you should no longer use MasterLabel, your code could fail - use ApiName instead:
LeadStatus CLeadStatus = [SELECT Id, ApiName FROM LeadStatus WHERE isConverted=true Limit 1];