Once a lead is converted it automatically creates an account, contact and one opportunity. But in my case i want to display the result without creating an Account. Please provide me with a sample code.
Any help will be appreciated...
There is no way you can stop Account creation on Lead conversion. The whole point of lead conversion to create Account so as to ensure business is taking place with the customer. However, you can stop Opportunity creation. You can either create new Account on lead conversion or merge with an existing account. The steps to convert lead using apex is:
1. Instantiate LeadConvert class. Database.LeadConvert dl = new Database.LeadConvert(); 2. There are 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);
Hope this helps.