You need to sign in to do that
Don't have an account?
Database.ConvertLead failing from trigger in Winter '13
I have a trigger that calls Database.ConvertLead when certain conditions are met.
This call succeeds in production (currently at Summer '12) but is failing in sandbox (currently at Winter '13).
We only have basic support so the help desk was not helpful. This is in spite of the fact that this is clearly a Winter '13 release issue.
Here is the error message.
System.DmlException: Update failed. First exception on row 0 with id a00V0000002mtbUIAQ; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FinancialAccountSummaryAutoConvert: execution of AfterUpdate 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: 297185815-14206 (-1560672462): [] Trigger.FinancialAccountSummaryAutoConvert: line 89,
This is on a Database.ConvertLead call from a trigger. I have other apex code that runs ConvertLead without issue in Winter '13. The error only happens when called from a trigger.
As of 9/27/2012 this error is no longer occurring. I assume an update to Winter '13 code took place in the last 24 hours that fixed this.
All Answers
Does trigger sends any emails, or uses any formula fields in the code? Did you tried running the code by setting debug log on?
The trigger does not use any formula fields.
Yes, I have run with debug monitoring on. Your comment motivated me to take another look at the log.
The call to Database.ConvertLead causes Lead triggers to fire. One of these triggers queries the Account record for the Account Id the lead converted to. The first internal error occurs here. See below.
13:08:09.730 (3730795000)|CODE_UNIT_FINISHED|LeadSetConversionKey on Lead trigger event BeforeUpdate for [00QV00000044M4D]
13:08:09.730 (3730898000)|CODE_UNIT_STARTED|[EXTERNAL]|01q70000000Kyup|LeadConversion on Lead trigger event BeforeUpdate for [00QV00000044M4D]
13:08:09.730 (3730992000)|USER_DEBUG|[15]|DEBUG|Lead Trigger fired
13:08:09.731 (3731009000)|SYSTEM_CONSTRUCTOR_ENTRY|[16]|<init>()
13:08:09.731 (3731016000)|SYSTEM_CONSTRUCTOR_EXIT|[16]|<init>()
13:08:09.731 (3731028000)|SYSTEM_CONSTRUCTOR_ENTRY|[17]|<init>()
13:08:09.731 (3731032000)|SYSTEM_CONSTRUCTOR_EXIT|[17]|<init>()
13:08:09.731 (3731182000)|USER_DEBUG|[20]|DEBUG|Lead Id: 00QV00000044M4DMAU
ConvertedAcctId 001V000000C4rDhIAJ Old Converted: null
13:08:09.731 (3731312000)|USER_DEBUG|[25]|DEBUG|Record Type 01270000000M9gWAAS Account Type null
13:08:09.731 (3731509000)|USER_DEBUG|[42]|DEBUG|Number of accounts is 1
13:08:09.731 (3731712000)|SOQL_EXECUTE_BEGIN|[44]|Aggregations:0|select Id, SIC, Description, BOK_Referral_Id__c, CreatedDate from Account where Id IN :tmpVar1
13:08:09.732 (3732676000)|FATAL_ERROR|Internal Salesforce.com Error
Here is the TestLeadAutoConvert code.
Here is the LeadConversion trigger code.
Since you are not getting a helpful error, I would try breaking out the select that it is dying on into its own line without assigning it to a map and make sure you are getting something back.
As of 9/27/2012 this error is no longer occurring. I assume an update to Winter '13 code took place in the last 24 hours that fixed this.