function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Surender reddy SalukutiSurender reddy Salukuti 

is there any way to restrict contact conversion while converting lead record ?

Hi all 

i have one requirement i am converting lead to account using custom logic preventing  Opportunity creation i need to prevent contact convertion also by suing any logic any one have any idea
please find below code which i am using 

 @AuraEnabled 
    public static id convertlead (Id recordId){
        id accountid;
        lead le = new lead();
        le.Id=recordId;
        le.RecordTypeId = Schema.SObjectType.Lead.getRecordTypeInfosByDeveloperName().get('Business_Insurance').getRecordTypeId();
         system.debug('recordtypeid--> '+le.RecordTypeId);
        Database.LeadConvert lc = new Database.LeadConvert();
        lc.setLeadId(le.Id);
         system.debug('lc value --> '+lc);
        LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
        lc.setConvertedStatus(convertStatus.MasterLabel);
        lc.setDoNotCreateOpportunity(true);
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        accountid =lcr.getAccountId();   
        return accountid;
    }

 

Thanks 

surender Reddy