QUESTION:
Custom triggers in my organization are causing DupeBlocker to not detect duplicates. How can this be resolved?
ANSWER:
There are multiple reasons that may result in DupeBlocker not detecting duplicates correctly. The majority are due to incomplete set-up/configuration, and/or misunderstanding how matching rules/mapping types works.
Please see the separate solution DupeBlocker NOT Detecting Duplicates for a list of the typical reasons duplicates are not being detected.
If after reviewing all of these possibilities none seem to explain/resolve the issue then the problem is likely due to a custom trigger on the object being checked for duplicates that is attempting to insert/update multiple objects in the same Apex batch. This can prevent DupeBlocker from properly preventing or warning about duplicates since it's considered a batch operation.
FOR EXAMPLE:
trigger CreateContact on Account (after insert)
{
Contact newConact = new Contact{ AccountId = trigger.new[0].Id };
insert newContact;
}
RESOLUTION:
To fix this issue you can convert the insert to an asynchronous (@future) call so that the insert is executed in a separate Apex batch. For example, the above code could be converted to this:
Create this apex class:
public class AccountHandler
{
@future public static void createFirstContact( Account parentAccount )
{
Contact newContact = new Contact{ AccountId = parentAccount.Id };
insert newContact;
}
}
Modify the trigger to use the new @future method:
trigger CreateContact on Account (after insert)
{
AccountHandler.createFirstContact( trigger.new[0] );
}
Note: This is just an asynchronous execution example, proper batching and exception handling are not shown.