4

I see this error I've never seen before and neither found anything about it on SE nor googling it.

The error is the following when converting a Lead :

12:34:34:099 EXCEPTION_THROWN [14]|System.DmlException: ConvertLead failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, We couldn’t convert the lead because it’s associated with events that aren’t accessible in Salesforce Classic. Try converting the lead in Lightning Experience.: []

Funny part is, obviously I'm On Lightning Experience, and if you do the according queries the Lead has 0 Events linked to it.

The conversion is done through an apex class with the following code :

public static Database.LeadConvertResult convertLead(Lead candidato, Boolean noCrearOpp){        
        
        Database.LeadConvert leadConvert = new database.LeadConvert();
        leadConvert.setLeadId(candidato.id);
        leadConvert.setDoNotCreateOpportunity(noCrearOpp);
        
        LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted = true LIMIT 1];
        leadConvert.setConvertedStatus(convertStatus.MasterLabel);
        Database.LeadConvertResult leadConvertResult = Database.convertLead(leadConvert);        
        
        return leadConvertResult;
    }

I'm executing the conversion as System Administrator.

Update: I cloned the lead and converted it using the stardard convert button, it worked. Although I don't get it why. The custom conversion process just calls the conversion code i posted up there and only then performs some other actions updating the account and doing some stuff over the opportunity, but the error thrown is on the line

Database.LeadConvertResult leadConvertResult = Database.convertLead(leadConvert);

What is producing this error?

2
  • Does this happen only for specific leads or for all the leads? Do you notice any pattern? Do you have any custom code for conversion?
    – Swetha
    Mar 1, 2021 at 13:13
  • This Happens using a custom code I will attach in the post. And only with this lead. All other leads convert acordingly to its processes correctly or throwing error accordingly to duplicate rules, other validations , etc. Mar 1, 2021 at 20:49

0

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.