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

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];

Database.LeadConvertResult lcr = Database.convertLead(lc);


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

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}"/>
and Method is crating a new lead there & the convert it
& after converting it was setting the final status of converted lead