Duplicate detection in Microsoft Dynamics is designed to help maintain data integrity. Duplicate detection rules can be configured for any entity and applied when:
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.
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.
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
3. Publish all
4. The solution publishes rules that were unpublished or modified in the last hour
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).