You need to sign in to do that
Don't have an account?

Can any one explain this senario...how to execute this class how to i will get output
public class LeadConvert {
public void writeRec()
{
Lead l = new Lead(LastName ='prasanth',company= 'infosys');
insert l;
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(l.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());
}
}
just create the object of LeadConvert & call the writeRec method
like this:-
LeadConvert Obj = new LeadConvert ();
Obj.writeRec();
or you can create a Visual force page
from where you can call this method like this:-
<apex:page controller="LeadConvert ">
<apex:commandbotton name="test" value="test" action="{!writeRec}"/>
</apex:page>
& after converting it was setting the final status of converted lead