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
Baratam DharaniBaratam Dharani 

Lead conversion using visualforce page

Hii all,
i need to convert Lead(standard Object) to accounts, contacts and opportunity using visualforce page. Can anyone provide me the code please

Thanks in advance
Maharajan CMaharajan C
Hi Dharani,

Please refer the below one:

https://github.com/Topalovich/leadConvert

Thanks,
Maharajan.C
Suraj Tripathi 47Suraj Tripathi 47
Hi Baratam Dharani,
Please consider the given link below-
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_convertLead.htm
http://salesforce.stackexchange.com/questions/4756/convert-lead-through-apex-but-should-not-create-opportunity
also, try to do by this method
public class LeadController {
    public List<Lead> leads { get; set; }
    
    public LeadController() {
        leads = new List<Lead>();
        leads = [
            SELECT  Name
                    ,Id
                    ,Company
                    ,Email
                    ,LastName
                    ,Phone
            FROM    Lead
        ];
    }
    
    /*@RemoteAction
    public static void convertLead( String id ) {
        Lead l = [
            SELECT  Id
            FROM    Lead
            WHERE   Id = :id
        ];
        
    }*/
    public static void doConvert( Id leadId ){

        Database.LeadConvert lConvert = new database.LeadConvert();
        lConvert.setLeadId( leadId );
        LeadStatus convertStatus = [
            SELECT  Id 
                    ,MasterLabel 
            FROM    LeadStatus 
            WHERE   IsConverted = true 
            LIMIT   1
        ];
        lConvert.setConvertedStatus( convertStatus.MasterLabel );
        Database.LeadConvertResult lConvertRes = Database.convertLead( lConvert );
    }
}
If you found this helpful,
Please mark it as the best answer.
Thank you