Skip to main content
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 件の回答
  1. 2018年1月22日 9:38
    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