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
vasu takasivasu takasi 

Convert lead through apex but should not create account

hi

 i want convert a lead from apex without creation of account

how is it possible?

public class LeadClass{
    public static void doConvert(Id leadId){

        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(leadId);
        lc.setDoNotCreateOpportunity(True); //**IMPORTANT METHOD HERE**

        LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
        lc.setConvertedStatus(convertStatus.MasterLabel);
        Database.LeadConvertResult lcr = Database.convertLead(lc);
    }
}

 

sfdcfoxsfdcfox
No, you can't convert a lead without creating an account or attaching to an existing account. Many clients that have this need opt for Person Accounts, or, if they do not use that feature, have a dummy account that all "non-account contacts" are assigned to. Not assigning a contact to an account has a negative effect on sharing permissions.