function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
I am new to Salesforce.comI am new to Salesforce.com 

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());
}


}

SRKSRK
you can run this piece of code from any apex class or developer consol
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>
SRKSRK
and Method is crating a new lead there & the convert it
& after converting it was setting the final status of converted lead