Thanks for your guys reply. I created the trigger on the DuplicateRecordItem which is the standard Duplicate checking function Object. The purpose is that I want to lookup the Lead / Account / Contact in the Duplicate Record Item. So that I can create a workflow rule to trigger the email alert to the duplicate record Item's Owner's Manager. Though there is a record field in that Object to link up to the Duplicate Record. But can't refer to the fields in it. The following is my code. But can't be triggered when I create a duplicate lead record.
trigger DuplicateRecordItemBeforeInsert on DuplicateRecordItem (before insert, before update) { System.debug('runing'); for(DuplicateRecordItem duplicateRecordItem : trigger.new){ System.debug('duplicateRecordItem.Record:' + duplicateRecordItem.Record); if (duplicateRecordItem.Record != null){ System.debug('duplicateRecordItem.Record.getsObjectType():' + duplicateRecordItem.Record.getsObjectType()); if (duplicateRecordItem.Record.getsObjectType() == Lead.sObjectType){ duplicateRecordItem.Lead__c = duplicateRecordItem.RecordId; } if (duplicateRecordItem.Record.getsObjectType() == Account.sObjectType){ duplicateRecordItem.Account__c = duplicateRecordItem.RecordId; } if (duplicateRecordItem.Record.getsObjectType() == Contact.sObjectType){ duplicateRecordItem.Contact__c = duplicateRecordItem.RecordId; } } } }
Could you please give some more detail about your issue. Where you write trigger for duplicate check?? If possible share your code.
Thanks
With Spring 15, you can create "Duplicate Rules" and "Matching Rules". Refer below URL for details:
https://help.salesforce.com/apex/HTViewHelpDoc?id=duplicate_prevention_map_of_concepts.htm&language=en_US
trigger DuplicateRecordItemBeforeInsert on DuplicateRecordItem (before insert, before update) {
System.debug('runing');
for(DuplicateRecordItem duplicateRecordItem : trigger.new){
System.debug('duplicateRecordItem.Record:' + duplicateRecordItem.Record);
if (duplicateRecordItem.Record != null){
System.debug('duplicateRecordItem.Record.getsObjectType():' + duplicateRecordItem.Record.getsObjectType());
if (duplicateRecordItem.Record.getsObjectType() == Lead.sObjectType){
duplicateRecordItem.Lead__c = duplicateRecordItem.RecordId;
}
if (duplicateRecordItem.Record.getsObjectType() == Account.sObjectType){
duplicateRecordItem.Account__c = duplicateRecordItem.RecordId;
}
if (duplicateRecordItem.Record.getsObjectType() == Contact.sObjectType){
duplicateRecordItem.Contact__c = duplicateRecordItem.RecordId;
}
}
}
}
I am also facing same issue, did you find any workaround/ solution ?