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
Aakash Saluja 7Aakash Saluja 7 

Rejecting duplicate records coming via integration

Hi,
I have a requirement where there is a need to stop the record from coming into salesforce if it is a duplicate record ,i.e, the same record is already present in the system. The records are coming via integration and are getting saved but the scenario says that they should not even get saved either if it is a duplicate.
Is there any way that this can be acheived?

Thanks
Rishabh Agrawal 18Rishabh Agrawal 18
You can create one unique external id field in your object where you are storing that data and tell the third party also that send some unique code for the records. 
Using unique external id field you can do insert on our system and if some record is already present with that id it will throw an exception and the record will not get inserted, You can catch that exception and log it somewhere if you wanted it for reporting or anything.
 
Manish  ChoudhariManish Choudhari
Hi Aakash,

What is the criteria or field values that determine if it is a duplicate record or not?

If it is ID field that determines duplication, then as Rishabh suggested, create an external id field on the object which will automatically take care of duplication.

But if it is other fields like Name or may be any custom field, then you can either use Duplicate Management feature OR you may have to write your logic in before insert trigger to identify duplicate record and neglect them.

For out of the box duplicate management feature checkout this pdf guide: http://resources.docs.salesforce.com/212/19/en-us/sfdc/pdf/salesforce_data_quality_duplicate_prevention.pdf 


Let me know if this helps.

**Please mark this as best answer if this answers your query.**

Thanks,
Manish Choudhari
14x Certified Salesforce Architect
Certification link: 
http://certification.salesforce.com/certification-detail-print?conId=003G000002gRrrEIAS 
My Blog: http://sfdcfacts.com/
Youtube Channel: https://www.youtube.com/SFDCFacts
LinkedIn: https://www.linkedin.com/in/manish-choudhary/
Trailhead: https://trailhead.salesforce.com/en/me/manish-choudhari
Twitter: https://mobile.twitter.com/manish_sfdc