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
vineet srivastava 10vineet srivastava 10 

need urgent help on lead conversion trigger without converting to account and contact...kindly help. Thanks.

Nitin Wader 21Nitin Wader 21
There is no way to stop Account creation on Lead conversion.
Objective of lead conversion to create Account and conclude business
But you can stop Opportunity creation.
You can either create new Account on lead conversion or merge with an existing account.
The code or logic to convert lead using apex is:

1. Instantiate -
    LeadConvert class. Database.LeadConvert dl = new Database.LeadConvert();

2. Some methods that need to be called out -
    Like: dl.setLeadId('Id of your lead'); dl.setDoNotCreateOpportunity(Boolean); dl.setOwnerId(ID); dl.setAccountId(ID);

//If you wanna merge lead with an existing account

3. Lastly you need to pass this instance to convertLead method: Database.LeadConvertResult result = Database.convertLead(dl);

Important Points:
You can leverage this lead conversion technique in trigger or apex class.
Keep the code bulkified because convertLead() method count against your DML statements.
It is  better to pass a list of LeadConvert class into this method.