I am getting the following error when DupeBlocker is attempting to auto-merge records. How can I resolve?
*** Executing Method: DB_AutoMerge.asyncMerge
*** Exception Type: System.DmlException
*** Exception Cause: null
*** Exception Message: Merge failed. First exception on row 0 with id 00Q2000000Jkd3rEAB; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MyLeadUpdate: execution of AfterUpdate caused by: System.AsyncException: Future method cannot be called from a future method: MyLeadUpdate (SET<Id>)
Note: A similar error may be generated when attempting to auto-convert.
The DupeBlocker auto-merge and auto-convert functions use asynchronous apex (@future calls).
When DupeBlocker attempts to auto-merge/convert records errors can occur when there is an existing trigger that performs an asynchronous operation and that trigger doesn't have any code to handle the case where it's being called from an asynchronous operation, e.g. a piece of code tries to execute an @future (asynchronous) call from inside an @future call. Unfortunately the only work-around for this is to modify the existing trigger with the @future call and add a try/catch handler around the @future call(s) to handle this exception.
One suggested method is to have a standard (synchronous) version of the @future call, put the core code in that method, then have the @future method call the standard method. Users can then check to see if their code is executing in an asynchronous/@future context and then execute the standard version of the method instead of the @future version. For example:
trigger MyTrigger on Object ( after insert )
if ( !System.isFuture() && !System.isBatch() )
@future void futureCall(<args>)
// Do all the work in this method