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
anthonymossit1.3956973255286362E12anthonymossit1.3956973255286362E12 

Lead Conversion Trigger Error - insufficient access

I've created a lead conversion trigger that is working in my dev org by not my production sandbox. I keep getting this error, which is strange because as system admin I clearly have "Edit" permission on accounts. Any thoughts?

Error Message:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger ConvertLeadtrigger caused an unexpected exception, contact your administrator: ConvertLeadtrigger: execution of AfterInsert caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, You do not have the required permission. To continue, you must have the 'Edit' permission on accounts : : []: Trigger.ConvertLeadtrigger: line 13, column 1

The Code:

trigger ConvertLeadtrigger on Lead (after insert) {
//Bulkified
   Integer Count =0;
    Database.LeadConvert lc = new Database.LeadConvert();
    for(Lead Lea : trigger.new){
        if(Lea.Convert__c == 'Trigger'){
          Database.LeadConvert convLead = new database.LeadConvert();
          lc.setLeadId(Lea.Id);
          LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
          lc.setConvertedStatus(convertStatus.MasterLabel);         
          lc.setAccountID('001i000000gKtwA');
          lc.setDoNotCreateOpportunity(true);
          Database.LeadConvertResult lcr = Database.convertLead(lc);
          System.assert(lcr.isSuccess());  }      
    }
}
 

kevin lamkevin lam
I just tried your trigger in my sandbox and it worked perfectly, the new lead was added as a contact to an existing account.
anthonymossit1.3956973255286362E12anthonymossit1.3956973255286362E12
Yes - it's strange. Like I said it works in my Dev org. Any ideas what would be causing this specific error in my production org? 
kevin lamkevin lam
Have you checked your profile in Production? Also, that particular account used for conversion?