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
pavan kumar 1156pavan kumar 1156 

Pls help me to write a trigger .!

Need tomerge the accounts and findout the duplicatea and eliminate them?
Naveen DhanarajNaveen Dhanaraj
Duplicate Management:
If you want to prevent from Entering Duplicate Records, you can use Standard Functionality Matching Rule and Duplicate Rule
These blogs will explain you step by step, (" target="_blank)

Matching Rule:
Duplicate Rule:

If you have already Duplicate Records then by using This App filter it,
Try This Apps,

Trigger to restrict after cleaning up the Duplicates,
trigger MatchEmailTrigger on CustomObj__c (before insert) {
    set<string> emailSet=new set<string>();
    list<contact> clist=[select id from contact where email in:emailSet];
    list<lead> leadList=[select id from lead where email in:emailSet];
    if(clist.size()>0 || leadList.size()>0)
        c.addError('Email Exists');

Dinesh MultaniDinesh Multani
If you just want to merge duplicate Account then instead of writing trigger you can use Salesforce's inbuilt functionality for merging the Accounts. Just visit your Accounts at the bottom that page there is a "Tools" section in this section click on "Merge Accounts" and then you can just move ahead with Accounts you need to merge or you can visit this link where it is discussed in detail