What is Duplicate Detection in Microsoft Dynamics CRM?

Duplicate detection in Microsoft Dynamics is designed to help maintain data integrity. Duplicate detection rules can be configured for any entity and applied when:

  • creating a record,
  • updating a record,
  • during imports,
  • as a scheduled job.

The problem with duplicate detection rules un-publishing

Last week I had a client come to me with an issue in Dynamics CRM where duplicate detection rules keep un-publishing. 

When installing a managed or unmanaged solution for Microsoft Dynamics CRM, extra care must be taken to ensure that all components of the system work as expected.

The reason? Whilst duplicate detection rules are not solution components, they are automatically unpublished whenever you publish a managed or unmanaged solution involving one of the entities referenced in the rule.

The problem is that this can easily go unnoticed.

How to ensure that duplicate detection rules remain published in Dynamics CRM / 365

Whilst duplicate detection rules un-publishing is commonplace, the popular solutions to the problem wouldn’t work for my client as they can only handle up to six rules for each entity. The other issue with existing solutions is error handling.

Therefore, I created a more efficient solution, that would not error when there are more than 6 rules for an entity, and have packaged it to share with anyone else struggling with this issue.

This works with all versions of Dynamics CRM 2016 (v8) and Dynamics 365 v9.

By default, it will only publish Duplicate Detection Rules that have been unpublished within the last hour.  The plugin registration contains the FetchXml query that selects the Duplicate Detection Rules that need republishing.   This is to allow users to exclude certain rules based on other criteria, an example might be to ignore all rules where the name contains ‘[DISABLED]’

If the FetchXml is deleted the plugin will default to publishing all unpublished Duplicate Detection Rules.

Download the solution here.

How the solution works

1. Import our solution and enable “any SDK messages processes steps” in the import wizard

2. Post solution import, that changed the company record, some rules have become unpublished

Duplicate detection rules

3. Publish all

Duplicate Detection Rules

4. The solution publishes rules that were unpublished or modified in the last hour

Publish Duplicate Detection Rules

5.  There is verbose logging in the plugin trace log.  You can enable and see the trace log by following the instructions in this post. (follow from step 3).

Zachery Walsh O'Brien

Written By: Zachery Walsh O'Brien

Zachery is a Web Developer with a great eye for front end web development. He has studied Graphic Design, received a Higher National Diploma in Visual Communications, and interned as a Graphic Designer upon leaving college in a digital design agency in Ireland. Zachery originally focused on WordPress web design but has now diversified his skillset towards a web development role being able to leverage many front end languages and frameworks.

Similar Stories


Fast guide: Mastering the Connections Table in Dataverse & Dynamics 365

When paired with the Dataverse and Dynamics 365 platform, Connections can be used to unlock the power of data relationships. Here, we reveal the many benefits of using Connections in... Read More


ChatGPT & Dynamics: How businesses can use this new power duo to improve customer service

Once the stuff of sci-fi films and the subject of much speculation, artificial intelligence is emerging in our work and personal lives at a rapidly-increasing rate. We’re talking chatbots, e-payments,... Read More


A day in the life of…our Microsoft Dynamics 365 developer, Zach

We’re fortunate to have some of the best software and business solutions talent in our team. In this Q&A blog series, we’re giving you a behind-the-scenes glimpse of who our... Read More