How to convert Lead without creating Opportunity in Salesforce?

Sample Code:

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';
lc.setDoNotCreateOpportunity(true);
Database.LeadConvertResult lcr = Database.convertLead(lc);                
System.assert(lcr.isSuccess());

Cheers!!!

No comments:

Post a Comment