1

Note : I have done CURD & FLS for Account & Contact which I have inserted already i.e. objAccount1 and objContact1

Code :

 //create an opp for each lead            
            Database.LeadConvert objLeadConvert = new Database.LeadConvert();
            objLeadConvert.setLeadId(myLead.Id);
            objLeadConvert.setAccountId(objAccount1.id);
            objLeadConvert.setContactId(objContact1.id);
            objLeadConvert.setDoNotCreateOpportunity(false);
            objLeadConvert.setOpportunityName(myLead.Company);            
            objLeadConvert.setConvertedStatus(convertStatus.MasterLabel);

            leadsToConvert.add(objLeadConvert);            

            try{
                 **ConvertResult= Database.convertLead(objLeadConvert,true);**   // ********for this line
                 ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Confirm, 'Your Leads are Converted Successfully!'));
                 isEditable=false;
                }
                catch(Exception ex){   }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.