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
sf sharathsf sharath 

how to convert lead in to account

Navatar_DbSupNavatar_DbSup

Hi,

Try these steps:

Go to the Lead Detail Page for a particular Record then Press the Convert button overt there and it will create the account as well as opportunity.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

vishal@forcevishal@force

if you want to do it through Apex,

 

below example should help you. 

 //Lead Conversion

        // creating a sample lead for conversion
        Lead ld1 = new Lead();
        ld1.lastName = 'test'; // these 2 are the required fields in my Org, as per your Org required fields 
        ld1.Company = 'test';    //  assign values to each of the required fields
        insert ld1;

        // converting the created lead
        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(ld1.id);
        //lc.setAccountId(acc2.Id); // you can set the Account Id to which you want the lead to be converted, if not specified, it creates a new account.
        //lc.setContactId(con3.id);  // you can set the Contact Id to which you want the lead to be converted, if not specified, it creates a new Contact.
        //lc.setDoNotCreateOpportunity(true); // this will not create a new opportunity on lead conversion
        
        LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
        lc.setConvertedStatus(convertStatus.MasterLabel);
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        System.assert(lcr.isSuccess());
        system.debug('-----------'+lcr.getContactId()); // will return you the converted Contact Id
        system.debug('-----------'+lcr.getAccountId()); // will return you the converted Account Id

 

Let me know if this helps :)