Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
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
30 answers
  1. Jan 22, 2018, 9:38 AM
    Hi Sarma,

    Add the below line of code in your existing code:

    lc.setDoNotCreateOpportunity(TRUE); after lc.setConvertedStatus(convertStatus.MasterLabel);

    This will not create an opportunity upon lead conversion.

    Let me know if it helps or you need more assistance.

    Thanks,

    Jainam Contractor,

    Salesforce Consultant,

    Varasi LLC,

    www.varasi.com
Loading
0/9000