Enable Javascript

Please enable Javascript to view website properly

Toll Free 1800 889 7020

Looking for an Expert Development Team? Take two weeks Trial! Try Now

Dynamics CRM Tips and Tricks – Using Alternate Key for Duplicate Detection

Follow Below Tips and Tricks

Duplicate detection feature was introduced long back in Dynamics CRM.

To enable it Navigate to Settings > Data Management and select Duplicate Detection Settings and select Enable duplicate detection option.

CRM tips

Next select Duplicate Detection Rules to either define the rule on which duplicate detection rule should run or click on the existing out of the box rules.

Here open the “Contacts with same first name and last name” rule

CRM tips

Below you can see the rule criteria

CRM tips

To see it action, you can try creating a new contact record with exact same first name and last name

CRM tips

Clicking on Save will allow you to create the duplicate contact record.

This is one of the limitations associated with Duplicate Detection Rule along with other limitation like that it works only for tables and not for phones, doesn’t work when lead is converted to account or contact using qualify button and also there can be only 5 duplicate detection rules per entity.

Thankfully now you have Alternate Key in Microsoft Dynamics CRM Development Services (introduced in CRM 2015 version), which you can use to prevent duplicate records to be created.

The basic purpose of alternate key is to help define any other field apart from the GUID as the primary key for the entity, to match with the external source in case of Data Migration.

Now let us define the alternate key on the First Name and Last Name field on the contact entity, similar to the above Duplicate Detection Rule.

Navigate to Customization > Customize the Entities > Entities and select the Contact entity and click on Keys.

Define the keys as shown below

CRM tips

Now try creating a new contact record with duplicate first name and last name, you should get the below error message

CRM tips

Defining alternate key makes sure that if records are getting created from code then also the check is applied i.e. server side. Basically, Dynamics CRM services creates a non-clustered unique index using the field defined in the database. One point we need to keep in mind is if any of the fields that are part of Alternate Key is blank or null then this check will not happen and record will not be identified as duplicate.

Thus, we saw in this article that how easy it is to have duplicate detection in place without writing any code or specifically server-side code like plugins, custom workflow activity etc.

Recent Blogs


NSS Note

Some of our clients