• chandra sekhar k 2
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi All,
Convert of Lead without Opportunity Object 
Hi All,
Convert of Lead without Opportunity Object 
Hi All,

How to do lead conversion without creating an opportunity. (Only account and contact has to be created)

If the account is already exists contact detailes has to updated to that exisiting account and if the details are already there in salesforce and different from the requirement, we need to update those details in account and contacts.

Lead Conversion Code:

Trigger web2LeadConvert on Lead (after Update) {
     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.Status == 'Qualified') {
               Database.LeadConvert lc = new Database.LeadConvert();
              
               
               lc.setLeadId(lead.Id);
              
               lc.setConvertedStatus(convertStatus.MasterLabel);
               
               leadConverts.add(lc);
          }
     }

     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }

Please help to slove above problems.

Regards,
Sarma