How
to convert lead using Apex
Lead myLead = new
Lead(LastName = 'Foo', Company='Foo Bar');
insert myLead;
Database.LeadConvert lc = new
database.LeadConvert();
lc.setLeadId(myLead.id);
LeadStatus convertStatus =
[SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult
lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
No comments:
Post a Comment