Implementing Duplicate Detection using Keys

Dynamics CRM contains duplicate detection feature, if want to know about this feature you can check here. This feature can be enabled for multiple operations for example, we can see different options under duplicate detection settings below:
duplicatedet1

These setting work differently based on operations for example if user will try to import data to respective entity for which you have duplication detection rule published. During data import user will get dialog where it will ask you for Allow Duplicates record like below:
duplicatedet2

So if user will say No, it won’t create any duplicate record whereas if user will try to create duplicate record manually in CRM it will show user a dialog but still user can click on save and it will create duplicate record. For example let’s say we have a duplicate detection rule published for account entity to check for duplicate based on email, if user will try to create account record with the same email id again it will show user a dialog with potential duplicate record but if user will click on Save it will allow you to save duplicate record.duplicate9

To stop creating duplicate we can simply use Keys to implement duplicate detection without any code. Let’s see how:
1. Go to Settings-> Customizations-> Customize the System
2. Expend Entities node and look for Account entity
3. Select Keys and click on New from right hand side
4. Select Email field under Available Attributes and click on Add button
5. Write Email under Display Name and click on Save.

Publish account entity and now when user will try to create account record again using email id which is used for existing account, user will get following error and it won’t let user to create duplicate record:

duplicate10

You can check our earlier article for how to use Keys for upsert.

Leave a Reply

Your email address will not be published. Required fields are marked *