+ Start a Discussion
lohith mlohith m 

leads to opportunities

I want to convert lead in to opportunity so i need easy and understanding code ....  thanks in advance... I am new to salesforce
Amit Chaudhary 8Amit Chaudhary 8
Hi Lohith,

Option 1:- You can use "LeadConvert Class"

Option 2:- You Can write Trigger
Trigger AutoConverter on Lead (after insert) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
     for (Lead lead: Trigger.new) {
          if (!lead.isConverted && lead.WebForm__c == 'Free Trial') {
               Database.LeadConvert lc = new Database.LeadConvert();
               String oppName = lead.Name;
     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);


Option 3:- Configuration :-

1) From the lead detail page, click Convert.
2) In the Account Name field, either select a new account or search for an existing one. For existing accounts, details about the lead appear in empty fields. The lead conversion preserves existing account data.
3) If you update an existing person account, select the option to overwrite the Lead Source field in the person account with the value from the lead.
In the Opportunity Name field, enter a name for the new opportunity, or select Do not create a new opportunity upon conversion if you don’t want to create an opportunity.
4) If you’d like, schedule a follow-up task under Task Information.
5) Click Convert. If your administrator set up Apex Lead Convert and Duplicate Management to help you manage and prevent duplicate records, and the lead conversion results in a duplicate record, you’ll see whether you may proceed with the conversion, or you need to resolve duplicates beforehand.

Please make this as solution is this will help you.
Amit Chaudhary
Amit Chaudhary 8Amit Chaudhary 8
Please mark above solution as best Solution if that will help you