Duplicate Detection Settings
Complete the full lesson to earn 25 points
Work through each section, then tap “Mark as Complete” on the last one.
✦ Skip the page breaks and see fewer ads — read each lesson on a single page with Pro
Managing Dataverse Duplicate Detection Settings
In any data-driven organization, the quality of your information is the foundation of your success. When you are working within Microsoft Dataverse, you are often dealing with thousands or even millions of rows of data coming from various sources: manual entry by users, automated imports from legacy systems, integrations with third-party marketing tools, and web-to-lead forms. Without a strategy to manage redundancy, your environment can quickly become cluttered with duplicate records. This leads to frustrated users who don't know which record is the "source of truth," inaccurate reporting for leadership, and wasted storage costs.
Duplicate detection in Dataverse is not just a checkbox you click; it is a multi-layered system designed to help you maintain a clean, professional database. It provides the tools to proactively prevent duplicates during data entry and retroactively identify them through bulk jobs. In this lesson, we will explore how to configure these settings, create effective rules, and implement best practices to ensure your data remains reliable and actionable.
Understanding the Core Concepts of Duplicate Detection
Before we dive into the technical configuration, it is essential to understand how Dataverse identifies a duplicate. Unlike a simple database query that might look for an exact match on a single column, Dataverse uses a system of "Match Codes." When you create or update a record, and a duplicate detection rule is active for that table, the system generates a match code based on the criteria you have defined.
These match codes are stored in a hidden system table. When a new record is saved, Dataverse generates its match code and compares it against the existing codes. If it finds a match, it triggers a warning to the user or flags the record for review. This architectural approach is efficient because the system doesn't have to scan every single record in your database every time someone hits "Save"; it only compares the pre-generated codes.
Why Duplicate Detection Matters for Your Business
Imagine a scenario where a sales representative, Sarah, creates a new Account for "Acme Corp." A week later, another representative, Jim, searches for "Acme Corporation" and, not seeing an exact match, creates a second record. Now, Sarah is logging calls on one record, while Jim is tracking emails on another. When the sales manager runs a report on total engagement with Acme, the data is split, leading to a poor understanding of the customer relationship.
By implementing duplicate detection, Jim would have received a warning the moment he tried to save "Acme Corporation," showing him Sarah’s existing "Acme Corp" record. This simple intervention saves time, prevents double-calling the customer, and keeps the data unified.
Callout: Duplicate Detection Rules vs. Alternate Keys
It is important to distinguish between Duplicate Detection Rules and Alternate Keys in Dataverse.
- Duplicate Detection Rules are "soft" constraints. They provide warnings to users in the UI and allow for fuzzy matching (like "First 5 characters"). They are designed for user-facing data entry and can be bypassed if the user or a process chooses to do so.
- Alternate Keys are "hard" constraints enforced at the database level. They require an exact match and will strictly prevent a record from being created if the key value already exists. Use Alternate Keys for integration IDs or unique identifiers where no exceptions are allowed.
Configuring Global Duplicate Detection Settings
The first step in managing duplicates is enabling the feature at the environment level. Even if you have defined specific rules for your tables, they will not function unless the global switches are turned on.
Enabling the Feature
To manage these settings, you must have the System Administrator or System Customizer security role.
- Navigate to the Power Platform Admin Center.
- Select your environment from the list.
- Go to Settings > Data management > Duplicate detection.
- Toggle the switch for Enable duplicate detection to On.
Once the global setting is enabled, you have three specific scenarios where you can choose to apply it:
- When a record is created or updated: This provides real-time warnings to users working in Model-driven apps.
- When the Dynamics 365 for Outlook goes from offline to online: This ensures that data captured while disconnected doesn't conflict with data already in the cloud.
- During data import: This allows the Import Wizard to flag duplicates found within your CSV or Excel files based on your active rules.
Note: Enabling these settings does not automatically start catching duplicates. You must also have "Published" duplicate detection rules for the specific tables you want to monitor, such as Accounts, Contacts, or Leads.
Creating and Managing Duplicate Detection Rules
A duplicate detection rule defines the logic the system uses to decide if two records are the same. Each rule is associated with a "Base Record Type" (the record being checked) and a "Matching Record Type" (the records being searched against). Usually, these are the same, but you can create cross-table rules—for example, checking if a new Lead already exists as a Contact.
Step-by-Step: Creating a New Rule
Let's walk through creating a rule for the Contact table that looks for people with the same email address.
- In the Power Apps portal, select your environment and go to Advanced Settings (the gear icon).
- Navigate to Settings > Data Management > Duplicate Detection Rules.
- Click New in the toolbar.
- Name and Description: Give it a clear name like "Contacts with same Email Address."
- Base Record Type: Select Contact.
- Matching Record Type: Select Contact.
- Criteria Grid:
- Field: Email
- Criteria: Exact Match
- Ignore Blank Values: Check this box. (If you don't, two contacts with no email address will be flagged as duplicates of each other).
- Case-sensitive: Usually, you want this unchecked for emails.
- Save the rule.
Understanding Match Criteria Options
When defining your criteria, you aren't limited to exact matches. Dataverse offers several powerful options:
- Exact Match: The values must be identical (excluding case if specified).
- Same First Characters: You can specify a number, such as the first 5 characters. This is great for company names (e.g., "Microsoft" and "Microsoft Corp" would match if you checked the first 9 characters).
- Same Last Characters: Useful for matching the end of a string, though used less frequently.
Publishing the Rule
A rule is "Inactive" when you first create it. To make it work, you must click Publish. When you publish a rule, Dataverse starts a background process to generate the match codes for every existing record in that table.
Warning: If you have a table with hundreds of thousands of records, publishing a rule can take some time. Avoid publishing multiple complex rules simultaneously during peak business hours, as the match code generation process consumes system resources.
Handling Duplicates in the User Interface
Once a rule is published, the user experience changes. When a user creates a new record that matches an existing one, a "Duplicate Records Found" dialog box appears.
This dialog doesn't block the user entirely. Instead, it shows the potential matches and gives the user two choices:
- Ignore and Save: The user acknowledges the warning but decides this record is actually unique (perhaps a different person with the same name).
- Cancel: The user stops the creation and goes to work on the existing record instead.
This "soft" approach is vital for maintaining user productivity. If the system was too aggressive and blocked every potential match, users might find workarounds or stop entering data altogether.
Practical Example: The "Lead to Contact" Rule
Often, a business will receive a Lead that is actually an existing customer (Contact). You can create a rule where the Base Record Type is Lead and the Matching Record Type is Contact.
If the email address on the new Lead matches an email on an existing Contact, the system will alert the salesperson. This allows them to disqualify the Lead and instead create an Opportunity directly against the existing Contact, keeping the customer's history in one place.
Bulk Duplicate Detection Jobs
While real-time detection is great for manual entry, it doesn't help with data that was already in the system before you created your rules. For this, we use Bulk Duplicate Detection Jobs.
These are scheduled or ad-hoc background processes that scan your data and produce a report of all identified duplicates.
Setting Up a Bulk Job
- Go to Settings > Data Management > Duplicate Detection Jobs.
- Click New.
- The wizard will guide you through selecting the table and the view (e.g., "All Active Contacts").
- You can set a schedule to run this job every 30 days, for example.
- You can also opt to receive an email notification when the job finishes.
Once the job is complete, you can view the results. The system provides a list of "Master" records and their "Duplicates." From here, an admin can manually merge the records or delete the extras.
Callout: The Power of Merging
When you find a duplicate, simply deleting one record is often the wrong move. That record might have related data—like phone calls, tasks, or invoices—attached to it. Dataverse's Merge functionality allows you to pick one record as the "Master" and choose which field values to keep from each record. Most importantly, it automatically re-parents all related activities and records to the Master record, ensuring no data is lost in the cleanup process.
Programmatic Duplicate Detection (For Developers)
Sometimes you are interacting with Dataverse through the Web API or the C# SDK rather than the standard UI. By default, API operations often bypass duplicate detection rules to ensure high performance during integrations. However, you can choose to enforce them.
Using the Web API
When performing a POST or PATCH request, you can include the MSCRM.SuppressDuplicateDetection header. If you set this to false, the system will check your rules.
POST [Organization URI]/api/data/v9.2/contacts
Content-Type: application/json
MSCRM.SuppressDuplicateDetection: false
{
"firstname": "John",
"lastname": "Doe",
"emailaddress1": "[email protected]"
}
If a duplicate is found, the API will return a 412 Precondition Failed error. Your application logic should be prepared to handle this error and either alert the user or log the conflict.
Using the C# SDK
If you are writing a custom plugin or a standalone .NET application, you can use the DuplicateDetection parameter in your CreateRequest or UpdateRequest.
Entity contact = new Entity("contact");
contact["firstname"] = "John";
contact["lastname"] = "Doe";
contact["emailaddress1"] = "[email protected]";
CreateRequest request = new CreateRequest
{
Target = contact
};
// This is the key line to enforce rules
request.Parameters.Add("SuppressDuplicateDetection", false);
try
{
CreateResponse response = (CreateResponse)service.Execute(request);
}
catch (FaultException<OrganizationServiceFault> ex)
{
if (ex.Detail.ErrorCode == -2147220685) // Duplicate Error Code
{
// Handle duplicate record found
Console.WriteLine("A duplicate record was detected. Please review the data.");
}
}
Best Practices for Duplicate Detection
Setting up rules is easy, but setting them up well requires strategy. Here are the industry standards for maintaining a clean environment.
1. Keep Rules Simple
The more fields you add to a single rule, the less likely it is to find a match. Dataverse rules use "AND" logic within the criteria grid. If you have a rule that checks for (First Name AND Last Name AND Email), a record with the same name but a different email won't be flagged. It is usually better to have several simple rules (one for Email, one for Phone Number) than one complex rule.
2. Always "Ignore Blank Values"
This is the most common mistake beginners make. If you are matching on a "Mobile Phone" field and you don't ignore blanks, every contact without a mobile phone will be considered a duplicate of every other contact without a mobile phone. This creates a massive amount of "noise" in your bulk detection jobs.
3. Exclude Inactive Records
When creating a rule, you have the option to exclude inactive records. In most business cases, you only care if the new record matches an active customer. If someone was a customer five years ago and their record is now deactivated, you might want to allow the creation of a new, fresh record rather than merging with a stale, inactive one.
4. Clean Before You Enable
If you are importing data into a brand new environment, it is often easier to clean the data in Excel or using a dedicated data cleansing tool before it hits Dataverse. Once the data is in and the rules are published, they are there to maintain the cleanliness you've established.
5. Use Fuzzy Matching Sparingly
While "First X Characters" is useful, it can lead to false positives. For example, matching on the first 3 characters of a Last Name would flag "Smi" for both "Smith" and "Smithson." Use enough characters to be meaningful (usually 5-10 for names).
Common Pitfalls and How to Avoid Them
Even with the best intentions, things can go wrong. Let's look at some common hurdles.
The "Too Many Rules" Limit
Dataverse has a limit on the number of active duplicate detection rules (usually around 5 per table). This forces you to be strategic. If you find you need more, consider if some rules can be combined or if you should be using Alternate Keys for some of that logic.
Performance Degradation
Every active rule adds a small amount of overhead to the "Save" operation. If you have 20 published rules across various tables, and you are doing a massive data import, the import will run significantly slower.
Solution: Unpublish duplicate detection rules during large data migrations or use the header/parameter to suppress detection for the service account performing the import. Run a Bulk Detection Job after the import is complete to find any duplicates that slipped through.
Rules Not Triggering in Power Automate
By default, the Power Automate "Add a new row" action for Dataverse does not trigger duplicate detection. Many admins are surprised when their automated flows create hundreds of duplicates.
Solution: Currently, there isn't a simple toggle in the Power Automate connector to enable this. You must either check for the record's existence manually within the flow (using a "List Rows" step with a filter) or use a custom Action/Plugin that enforces detection.
Comparison: Duplicate Detection vs. Other Data Quality Tools
| Feature | Duplicate Detection Rules | Alternate Keys | Power Automate / Logic Apps |
|---|---|---|---|
| Enforcement | Soft (Warning) | Hard (Block) | Custom Logic |
| Fuzzy Matching | Yes (First X chars) | No (Exact only) | Yes (via expressions) |
| UI Support | Native Dialog Box | Error Message | None (Background) |
| Performance | Medium | High | Low (due to extra steps) |
| Complexity | Simple Configuration | Simple Configuration | High (requires coding/logic) |
Quick Reference: Duplicate Detection Statuses
When you look at your list of rules, you will see different statuses. Understanding these is key to troubleshooting:
- Draft: The rule is being edited and is not active.
- Publishing: The system is currently generating match codes for existing data.
- Published: The rule is active and working.
- Unpublishing: The system is removing the match codes for this rule.
- Inactive: The rule is saved but not currently being used by the system.
Summary and Key Takeaways
Managing duplicate detection in Microsoft Dataverse is a balance between data integrity and user experience. By following the steps and best practices outlined in this lesson, you can build a system that supports your users rather than hindering them.
Remember that data quality is a journey, not a destination. Your rules will likely need to evolve as your business grows and as you identify new patterns in how data enters your system. Regularly reviewing your Bulk Detection Jobs and refining your rules ensures that your Dataverse environment remains a "single source of truth" that your organization can rely on.
Key Takeaways
- Enable Globally First: Duplicate detection must be enabled at the environment level in the Power Platform Admin Center before individual rules will function.
- Match Codes are Key: Dataverse uses match codes to compare records efficiently; these are generated in the background when a rule is published or a record is updated.
- Use "Ignore Blank Values": To avoid flagging every record with empty fields as a duplicate, always check the "Ignore Blank Values" box in your rule criteria.
- Merge, Don't Just Delete: Use the native Merge functionality to combine duplicates, ensuring that all related activities and child records are preserved and moved to the master record.
- Strategic Rule Design: Prefer multiple simple rules over one complex rule, as Dataverse uses "AND" logic within a single rule's criteria.
- Bulk Jobs for Maintenance: Use Bulk Duplicate Detection Jobs to clean up existing data and schedule them to run periodically to catch duplicates created by integrations or imports.
- Know When to Use Alternate Keys: If you need to strictly prevent duplicates (like an Account Number) at the database level with no exceptions, use Alternate Keys instead of Duplicate Detection Rules.
- Developer Control: Developers can choose to enforce or bypass duplicate detection in API calls using the
SuppressDuplicateDetectionheader or parameter.
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles your daily points limit so you progress twice as fast, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× daily points limit
- ✓ Distraction-free lessons