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
Sfdc wonderSfdc wonder 

How to remove duplicate records


i have one requirement regarding avoid duplicates of products in salesforce.i.e,any new Product with same info like Name,Productcode matches with existing product record,the old one can be deleted and new one will be inserted.

can any one suggest me how to achieve this....
Kripa Sindhu SinghKripa Sindhu Singh
Hi Ram,

there are some tools available in Appexchange to check duplicate values on the any object 

like dupe catcher etc.

But if want this thing to be done from the code, you have to write a trigger for that whcih will check for the new inputs made by you.

you can write a trigger on the product2 object which will act berfore insert and update,

and check for the duplicate if duplicate value found the values are not submitted and throws error.

For the above another work around can be made by making Name, Product Code etc, as unique fields.

for more refference you can check this link.

Shri RajShri Raj
Write a BATCH Class which runs everyday to clean up the data with the conditions you have mentioned. 
Dan taceloskyDan tacelosky
​It is possible to achieve removal of duplicate records of products in Salesforce with 360 Merge Duplicates App. The app has all the requisite functionalities that you are seeking in order to avoid duplication of records in your database. The app has features such as Auto-Merge, mass merge, and manually merge duplicate records that allow you to do away with duplicate records without losing any important data.

To know more about the app, all you have to do is to visit the following link: