BulkDetectDuplicatesRequest Class


Updated: November 29, 2016

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

Contains the data that is needed to submit an asynchronous system job that detects and logs multiple duplicate records.

For the Web API use the BulkDetectDuplicates Action.

Web API support for this message was added with December 2016 update for Microsoft Dynamics 365 (online) and December 2016 Service Pack for Microsoft Dynamics 365 (on-premises) 

Namespace:   Microsoft.Crm.Sdk.Messages
Assembly:  Microsoft.Crm.Sdk.Proxy (in Microsoft.Crm.Sdk.Proxy.dll)


[DataContractAttribute(Namespace = "http://schemas.microsoft.com/crm/2011/Contracts")]
public sealed class BulkDetectDuplicatesRequest : OrganizationRequest


Initializes a new instance of the BulkDetectDuplicatesRequest class.


Gets or sets an array of IDs for the system users (users) who are listed in the Cc box of the email notification.


Gets or sets the structure that contains extra data. Optional.(Inherited from OrganizationRequest.)


Gets or sets the indexer for the Parameters collection.(Inherited from OrganizationRequest.)


Gets or sets the name of the asynchronous system job that detects and logs multiple duplicate records. Required.


Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.(Inherited from OrganizationRequest.)


Gets or sets the query criteria for detecting multiple duplicate records. Required.


Gets or sets the recurrence pattern for the asynchronous system job that detects multiple duplicate records. Optional.


Gets or sets the start date and time of an asynchronous system job that detects and logs multiple duplicate records. Optional.


Gets or sets the ID of an asynchronous operation (system job). Optional. (Inherited from OrganizationRequest.)


Gets or sets the name of the request. Required, but is supplied by derived classes.(Inherited from OrganizationRequest.)


Gets or sets a value that indicates whether an email notification is sent after the asynchronous system job that detects multiple duplicate records finishes running. Required.


Sets the ID of the template (email template) that is used for the email notification.


Gets or sets an array of IDs for the system users (users) who are listed in the “To” box (recipients) of the email notification.


(Inherited from Object.)


(Inherited from Object.)


(Inherited from Object.)


(Inherited from Object.)

Message Availability

For this message to work, the caller must be connected to the server.


Pass an instance of this class to the Execute method, which returns an instance of the BulkDetectDuplicatesResponse class.

Privileges and Access Rights

To perform this action, the caller must have access rights on the entity records that are specified in the request class. For a complete list of the required privileges, see BulkDetectDuplicates message privileges.

Notes for Callers

The asynchronous system job detects multiple duplicate records and logs them as duplicate records by using the DuplicateRecord entity. Before you use this message, set the IsDuplicateDetectionEnabled attribute for an entity to true and publish all duplicate rules (duplicate detection rules) for an entity.

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface. For the complete sample, see the link later in this topic.

// Connect to the Organization service. 
// The using statement assures that the service proxy will be properly disposed.
using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,
                                                     serverConfig.Credentials, serverConfig.DeviceCredentials))
    // This statement is required to enable early-bound type support.


    // Create the BulkDetectDuplicatesRequest object
    Console.WriteLine("  Creating the BulkDetectDuplicatesRequest object");
    BulkDetectDuplicatesRequest request = new BulkDetectDuplicatesRequest()
        JobName = "Detect Duplicate Accounts",
        Query = new QueryExpression()
            EntityName = Account.EntityLogicalName,
            ColumnSet = new ColumnSet(true)
        RecurrencePattern = String.Empty,
        RecurrenceStartTime = DateTime.Now,
        ToRecipients = new Guid[0],
        CCRecipients = new Guid[0]

    // Execute the request
    Console.WriteLine("  Executing BulkDetectDuplicatesRequest");
    _response = (BulkDetectDuplicatesResponse)_serviceProxy

    #region check success

    Console.WriteLine("  Waiting for job to complete...");
    WaitForAsyncJobToFinish(_response.JobId, 120);

    QueryByAttribute query = new QueryByAttribute()
        ColumnSet = new ColumnSet(true),
        EntityName = "duplicaterecord"
    EntityCollection results = _serviceProxy.RetrieveMultiple(query);

    // check to make sure each id is found in the collection
    var duplicateIds = results.Entities.Select((entity) => 
    foreach (var id in _duplicateAccounts.Select((account) => account.Id))
        if (!duplicateIds.Contains(id))
            throw new Exception(String.Format(
                "Account with ID {0} was not detected as a duplicate",
    Console.WriteLine("  All accounts detected as duplicates successfully");




Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright

Community Additions