• Nathan Kramer
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
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;
       
    }
}