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
Salesforce####Salesforce#### 

trigger to eliminate duplicate name and phone number and email in account

how to  eliminate duplicates  name and phone number and email  using soql query in a single trigger while creating accounts ???
alternate approach is also fine other than filering in soql 
Alain CabonAlain Cabon
Hi,

Deleting or merging your duplicate accounts? There are the problem of the existing duplicates and the check for the future creations that prevents duplicates.

1) The check for the future creations that prevents duplicates is easy with a trigger (just read the account with the same name or phone number or email with "before insert, before update" and generate an addError like here:  https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_pattern_and_matcher_example.htm  ).

2) For the existing duplicates, it is more complex if you don't use the pre-existing powerful screens of Salesforce for individual merges manually based on lists sent to the owners of the accounts.

User-added image

User-added image
User-added image
User-added image

 The owners of the accounts will decide what they want to keep account by account and field by field.

Alain