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
Sunil Kumar 545Sunil Kumar 545 

hi,lead conversion using apex class

passing parameter method (first name,lastname,eamil)
check query with lead .eamil is there or not,
if lead exit means it converted to (con/acc),
if does not exit means(contact or account)
using apex class..
SandhyaSandhya (Salesforce Developers) 
Hi,

Below is the sample code you can use.
 
Lead myLead = new Lead(LastName = 'Foo', Company='Foo Bar');
insert myLead;    
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myLead.id);
lc.ConvertedStatus = 'Closed - Converted';
Database.LeadConvertResult lcr = Database.convertLead(lc);                
System.assert(lcr.isSuccess());

Refer below links for more information.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_convertLead.htm

https://automationchampion.com/tag/auto-convert-lead-using-apex/
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 
 
Sunil Kumar 545Sunil Kumar 545
check whether email is there or not in lead object ...if lead exist means convert to contact and account 
if it does not exist means it sholud be contact using apex class ...send code in only apex class..