You need to sign in to do that
Don't have an account?

FATAL_ERROR Database.convertLead failed
Hi everyone,
We are currently trying to migrate our code to production, but this FATAL_ERROR|Internal Salesforce.com Error is stopping us.
Here is the code from the triggers that cause this error.
trigger triggerDNC on Contact (before insert, before update) { List<Contact> conList = new List<Contact>(); List<String> accList = new List<String>(); if (Trigger.isInsert) { for (Contact c : Trigger.new) { boolean hasAccount = true; if (c.AccountId == null) { hasAccount = false; } else { conList.add(c); accList.add(c.AccountId); } } List<Account> checkAccList = new List<Account>(); if (!accList.isEmpty()) { checkAccList = [SELECT Id, BillingState FROM Account WHERE Id IN :accList]; // this is where the error gets generated from !!! for (Account a : checkAccList) { // do stuff .. doesnt get here } } } }
trigger LeadConversionTrigger on Lead (after insert,after update) { try{ list<Lead> oldlead= Trigger.old; list<Lead> newLead=Trigger.new; Account acc= new Account(); RecordType rdc= new RecordType(); rdc=[select Id, name from RecordType where RecordType.Name ='FromWeb' limit 1]; map<id, id> map_OppCon_id = new map<id, id>(); for(Lead LeadtoWork: newLead ) { Database.Leadconvert lc= new Database.Leadconvert(); lc.setLeadId(leadtoWork.Id); lc.setOverwriteLeadSource(true); lc.setConvertedStatus('Qualified'); lc.setOpportunityName('Opportunity From Web'); acc.RecordTypeId=rdc.Id; Database.Leadconvertresult lcr = Database.convertLead(lc); if(lcr.isSuccess()) { // do stuff doesnt get here } // do more stuff after, but doesnt get here } } catch(Exception e){System.debug('exception is>>>>'+e);} // goes to here after database.convertLead }
And here is the test that fails.
@isTest private class TriggertestClass { static testMethod void myUnitTest() { Lead l1= new Lead(); l1.LastName='lead'; l1.FirstName='test'; l1.Company='test comapny'; l1.Status='Open'; l1.OwnerId='111111111111111'; l1.LeadSource='Webdialer'; insert l1; } }
Here is the full description of the error from the debug log:
08:50:48.076 (1076907000)|SOQL_EXECUTE_BEGIN|[94]|Aggregations:0|select Id, BillingState from Account where Id IN :tmpVar1
08:50:48.078 (1078686000)|FATAL_ERROR|Internal Salesforce.com Error
08:50:48.078 (1078908000)|CODE_UNIT_FINISHED|triggerDNC on Contact trigger event BeforeInsert for [new]
08:50:48.090 (1090919000)|FATAL_ERROR|Internal Salesforce.com Error
08:50:48.097 (1097238000)|DML_END|[33]
08:50:48.097 (1097393000)|EXCEPTION_THROWN|[33]|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: ---: []
Any help would be greatly appreciated.
It could just be something as simple as the fact that your OwnerId in the test is not a valid Id.
In your test try querying the Id of an active user and using that Id instead of '111111111111111'
We do use a corect active user id, I just put the 1's there to omit any uneccesarry data.