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
Prakhyat sapraPrakhyat sapra 

how can i insert the a lead record through apex class?

how can i insert the a lead record through apex class?
Best Answer chosen by Prakhyat sapra
mukesh guptamukesh gupta
Hi Prakhyat

Please follow below code:-
 
public with sharing class CreateNewLead {
    public static void  CreateLead()
    {
	Lead lstLead =   new Lead();
        lstLead.Company = 'Test';
        lstLead.LastName = 'Prakhyat';
        lstLead.Status = 'Open';               
        insert lstLead;   
        
       
    }
    
}


if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh