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...
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
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.