[D365] How to create an alternate key

This post will show you how to quickly create an alternate key. If you want to know more about alternate keys please check out this post.

First you should open your customizations (either default solution or a dedicated solution that contains your customizations) and go to the entity where you want to create an alternate key.

In this post I’ll create an alternate key on contact entity using emailaddress1 field.

alternatekey

Select now one or more available attributes, I selected Email (emailaddres1)

selected attribute

Now you can save and close. A system job creates an index for Email in the database. The status changes from “pending” to “Active”

pending

active

You can now test your alternate key by creating two contacts with the same email address, while creating the second record you should have the following error

duplicaterecord

 

Make your first duplicate detection rule

This is a quick tip to help you create your first duplicate detection rule in Dynamics365 for Customer Engagement.

First navigate to Settings->Data Management->Duplicate Detection Rule

datamanagement

duplicate detection rules

You have already some default duplication detection rules that you can use or unpublish. It is important to know that a duplication detection rule works only if it’s published and that you can have up to 5 maximum rules per entity.

Let’s create a simple duplication detection rule on Contact entity Mobile phone field, so when you create or update a contact with the same mobile phone number of another contact it will generate an alert. Click New to create a new rule.

newrule

Note that you have several options such as excluding inactive matching contact records and the ability to choose whether you want a case-sensitive rule or not by checking the corresponding box. You can also choose to ignore blank values.

myrule

Choose a field and a criteria (I took Exact Match) then save and do not forget to publish (buttons are at the top of the window).

save&publish

Let’s now test our published new duplication detection rule, I’ll create a contact test1 with 07123456 as a mobile phone number then I’ll try to create a second one test2 with the same mobile phone.

contact1

When trying to save my contact2 record I get the following popup which means that the duplication detection rule has been triggered

popup

You can choose to Ignore and Save so in this case contact 2 is saved with the same value in mobile phone number field as contact 1, otherwise you can cancel and get back to the record and update it with a different mobile phone number.