This documentation is archived and is not being maintained.

Running Duplicate Detection

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

There are several ways to perform duplicate detection after you enable it and publish the duplicate detection rules:

  • You can detect duplicates for a specified entity instance by using the RetrieveDuplicates message. For example, you can use this message to find all the contacts that are duplicates of a particular account entity instance.
  • You can detect duplicates for an entity type by using the BulkDetectDuplicates message. This message submits an asynchronous duplicate detection job that runs in the background. The BulkDetectDuplicates message is used to find the duplicate entity instances for a specified entity type based on the query expression passed in this message request. The duplicates are detected according to the published duplicate rules for the entity type. The detected duplicates are stored as duplicate record entity instances in Microsoft Dynamics CRM. You can retrieve duplicate records by using the Retrieve method or the RetrieveMultiple method.
  • You can detect duplicates during Create and Update operations by passing the duplicate detection option in the OptionalParameters property of the CreateRequest and UpdateRequest message requests. The OptionalParameters property determines whether the Create or Update operations can complete based on one of the following values that are passed in CreateDuplicatesOptionalParameter:
    • true – Create or update an entity instance if a duplicate is found.
    • false - Do not create or update an entity instance if a duplicate is found.
    • null -  Defaults to true.

    If the duplicate detection option is set to false and a duplicate is found, an exception is thrown and the entity instance is not created or updated.

    The following examples show you how to pass the duplicate detection option as a part of the CreateRequest and UpdateRequest message requests.

    // Create operation – do not create, if a duplicate exists.
    CreateRequest reqcreate = new CreateRequest();
    reqcreate.OptionalParameters = new OptionalParameter[] { new CreateDuplicatesOptionalParameter(false) };
    // Update operation – do not update, if a duplicate exists.
    UpdateRequest requpdate = new UpdateRequest();
    requpdate.OptionalParameters = new OptionalParameter[] { new CreateDuplicatesOptionalParameter(false) }; 

See Also


Other Resources


© 2010 Microsoft Corporation. All rights reserved.