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
Vandana RattanVandana Rattan 

Lead Auto Convert Trigger Error

I have written a trigger (in Sandbox) to auto convert a lead when the Lead Source is  GetTimely Online. The test class has also been written for the same. However while running the test class I am getting the error mentioned below. I have searched a lot but am unable to fix the issue. Can anyone tell what could the issue be.

Trigger Error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AutoLeadConvert: execution of AfterInsert

 
caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, An unexpected error occurred. Please include this ErrorId if you contact support: 430269022-7994 (647855467): []

 
Trigger.AutoLeadConvert: line 7, column 1: []

My Trigger:-


trigger AutoLeadConvert on Lead (after insert) {
    for(Lead myLead: Trigger.new){
        if((myLead.isConverted==false) && (myLead.leadSource=='GetTimely Online')){
            try{
            Database.LeadConvert leadConvert = new database.LeadConvert();
            leadConvert.setLeadId(myLead.Id);
            leadConvert.convertedStatus='Qualified';
            Database.LeadConvertResult leadConvertResult = Database.convertLead(leadConvert);
            System.assert(leadConvertResult.isSuccess());
            }
            catch(DmlException e){
                System.debug('Exception-->'+e.getMessage());
            }
        }
       
    }
}

Test Class:-

@isTest
public class TestAutoLeadConvert{
    static testMethod void convertLead(){
        Lead lead = new Lead();
        lead.FirstName='Trigger';
        lead.LastName='Test';
        lead.Company='Trigger Test';
        lead.Email='vandana.rattan1982@gmail.com' (mailto:lead.Email='vandana.rattan1982@gmail.com');
        lead.LeadSource='GetTimely Online';
        lead.OwnerId='005900000026XgG';
        lead.Handicap__c=14;
        lead.PostCode__c='1234';
        lead.Status='Qualified';
        insert lead;
       
    }
}


 
AmitSahuAmitSahu
In the test class the email id should not contain the mail to,  i think.  Just use simple email address.  
Vandana RattanVandana Rattan
The test class is sans mail to. It is still giving the same issue. The test class is as shown below:-

 @isTest
public class TestAutoLeadConvert{
    static testMethod void convertLead(){
        Lead lead = new Lead();
        lead.FirstName='Trigger';
        lead.LastName='Test';
        lead.Company='Trigger Test';
        lead.Email='vandana.rattan1982@gmail.com' (mailto:lead.Email='vandana.rattan1982@gmail.com')
         lead.LeadSource='GetTimely Online';
        lead.OwnerId='005900000026XgG';
        lead.Handicap__c=14;
        lead.PostCode__c='1234';
        lead.Status='Qualified';
        insert lead;
       
    }
}
Vandana RattanVandana Rattan
I did some modifications in my Test class which leads my test case to pass. But the logs show an Internal Salesforce.com error. The log entries are given below:-

21:01:37:018 ENTERING_MANAGED_PKG sfxerope
21:01:37:019 HEAP_ALLOCATE [EXTERNAL]|Bytes:16
21:01:37:019 VARIABLE_SCOPE_BEGIN [1]|this|sfxerope.SyncWithXero|true|false
21:01:37:019 VARIABLE_ASSIGNMENT [1]|this|{}|0x6706da9c
21:01:37:020 DML_BEGIN [12]|Op:Insert|Type:sfxerope__Configuration__c|Rows:1
21:01:37:035 DML_END [12]|
21:01:37:042 FATAL_ERROR Internal Salesforce.com Error
21:01:37:046 DML_END [12]|

I cannot see any account, contact or opportunity created. Has anyone faced such issue?
 
Nathan KramerNathan Kramer

Hi Vandana,

What modifications did you make to your test class?

What does it look like now?