Convert lead using Apex #inSalesforce
Try in the Anonymous window in Developer Console -
Lead theLead = new Lead(LastName = 'thelastName', Company='theCompany',Email='abc.abc@abc.com');
insert theLead;
Database.LeadConvert convertLead = new database.LeadConvert();
convertLead.setLeadId(theLead.id);
convertLead.ConvertedStatus = 'Closed - Converted';
Database.LeadConvertResult convertedLead = Database.convertLead(convertLead);
system.debug('!!theConvertedLeadis!!'+convertedLead);
System.assert(convertedLead.isSuccess());
insert theLead;
Database.LeadConvert convertLead = new database.LeadConvert();
convertLead.setLeadId(theLead.id);
convertLead.ConvertedStatus = 'Closed - Converted';
Database.LeadConvertResult convertedLead = Database.convertLead(convertLead);
system.debug('!!theConvertedLeadis!!'+convertedLead);
System.assert(convertedLead.isSuccess());
Comments
Post a Comment