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?

3
  • 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? 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
  • This error occurs if the value in the picklist field on the Lead object that is mapped to picklist field either on Account, Contact, and Opportunity doesn't have a similar value in it and has the "Restrict picklist to values defined in the value set" setting enabled. To troubleshoot this issue, you can try disabling the "Restrict picklist" setting. However, if the picklist is a global picklist, this isn't an option as that setting can't be changed for these types of fields.
    – Gleison
    Feb 12 at 13:09

0

You must log in to answer this question.

Browse other questions tagged .