function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Patrick WongPatrick Wong 

Lead Duplicate Checking Function

Why the Duplicate Record Items Trigger can't be run while Duplicate Lead is Created?
Pritam ShekhawatPritam Shekhawat
Hello Patrick ,
                     Could you please give some more detail about your issue. Where you write trigger for duplicate check?? If possible share your code.

Thanks
Anand SinghAnand Singh

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

Patrick WongPatrick Wong
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;
            }
        }                
    }
}
Stephen Lombard 10Stephen Lombard 10
Patrick, did you get arount this. Same issue for me, Trigger does not seem to be getting called.
Sonal GuptaSonal Gupta
Hi @Patrick Wong,
I am also facing same issue, did you find any workaround/ solution ?