0

Facing this issue on production. On sandbox it is working fine.

Converting the lead to business account and contact but on production for few records it is failing.

Code for lead conversion.

{
    Database.LeadConvert leadConvert;
    leadConvert = new database.LeadConvert();
    leadConvert.setLeadId(leadId);
    leadConvert.setDoNotCreateOpportunity(true);
    leadConvert.setAccountId(mappedAccountId);
    leadConvert.setContactId(mappedContactId);
    LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
    leadConvert.setConvertedStatus(convertStatus.MasterLabel);
    List<Database.LeadConvertResult> leadConversionResults = Database.convertLead( new list<database.LeadConvert>{leadConvert} );
    System.debug(leadConversionResults);
    Lead leadData = [select id, status from lead where id = :leadId limit 1];
    leadData.status = LEAD_CONVERT_STATUS_QUALIFIED;
    update leadData;
    System.debug(leadData);

MappedAccountData is like this after debug.

22:03:33:222 USER_DEBUG [150]|DEBUG|Account:{RecordTypeId=0121r00000071g2A1E, Name=Test, BusinessId__c=2832152-1, OwnerId=0051r24000At3eAAAR, Selected_Area__c=TestArea, NumberOfEmployees=1, Data_source__c=Test, AccountSource=Website, NumberOfEntrepreneurs__c=1, Id=0016900002YXQ36AAH}

Error Screenshot:

enter image description here

How it can be fixed? What is the problem it is working fine for many records on production but for few it is giving error?

3

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.