Ignoring Activated Duplicate Detection Rules using the Dynamics CRM SDK

Ahmed Anwar, 25 November 2014

When creating a new record using the CreateRequest, you can pass a parameter to the message to ignore the Activated Duplicate Detection rules. Rather than programmatically unpublishing related Duplicate Detection rules in a custom integration or migration tool, you can now keep your rules published and ignore the rules with a single line of code.

Let’s go through a typical scenario.

In Dynamics CRM, I have a published Detection Rule on the Account Entity as bellow:

Ignoring Activated Duplicate Detection Rules using the CRM SDK

If I run this below code the first time, a new record will be created:

Ignoring Activated Duplicate Detection Rules using the CRM SDK

Running the same code again will throw an exception by the CRM platform as shown in the screenshot below.

Ignoring Activated Duplicate Detection Rules using the CRM SDK

To ignore or suppress the active duplicate detection rules you can simply set the SuppressDuplicateDetection property to true.

Entity target = new Entity("account");
target["name"] = "I am a clone";
CreateRequest req = new CreateRequest();
req.Target = target;
req["SuppressDuplicateDetection"] = true;
CreateResponse response = (CreateResponse)_service.Execute(req); 

Note that the example above uses the CreateRequest, but we can also suppress duplicate detection rules for the UpdateRequest.