Convert Lead through code

Lead myLead = new Lead(LastName = 'Fry', Company='Fry And Sons');
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);
//or  lc.convertedStatus = 'Qualified - Enrolled';

Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());


--------------------------------------

LeadConvert Constructors

The following are constructors for LeadConvert.

LeadConvert()

Creates a new instance of the Database.LeadConvert class.

Signature

public LeadConvert()

LeadConvert Methods

The following are methods for LeadConvert. All are instance methods.

1 comment:

Ruby said...

They will cope with web desiners want you are their circle of relatives

Counters