Bagikan melalui


BulkDetectDuplicatesRequest Class

 

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)

Inheritance Hierarchy

System.Object
  Microsoft.Xrm.Sdk.OrganizationRequest
    Microsoft.Crm.Sdk.Messages.BulkDetectDuplicatesRequest

Syntax

[DataContractAttribute(Namespace = "https://schemas.microsoft.com/crm/2011/Contracts")]
public sealed class BulkDetectDuplicatesRequest : OrganizationRequest
<DataContractAttribute(Namespace := "https://schemas.microsoft.com/crm/2011/Contracts")>
Public NotInheritable Class BulkDetectDuplicatesRequest
    Inherits OrganizationRequest

Constructors

Name Description
System_CAPS_pubmethod BulkDetectDuplicatesRequest()

Initializes a new instance of the BulkDetectDuplicatesRequest class.

Properties

Name Description
System_CAPS_pubproperty CCRecipients

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

System_CAPS_pubproperty ExtensionData

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

System_CAPS_pubproperty Item[String]

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

System_CAPS_pubproperty JobName

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

System_CAPS_pubproperty Parameters

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

System_CAPS_pubproperty Query

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

System_CAPS_pubproperty RecurrencePattern

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

System_CAPS_pubproperty RecurrenceStartTime

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

System_CAPS_pubproperty RequestId

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

System_CAPS_pubproperty RequestName

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

System_CAPS_pubproperty SendEmailNotification

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.

System_CAPS_pubproperty TemplateId

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

System_CAPS_pubproperty ToRecipients

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

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

Remarks

Message Availability

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

Usage

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.

Examples

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.
    _serviceProxy.EnableProxyTypes();

    CreateRequiredRecords();

    // 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
        .Execute(request);

    #region check success

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

    QueryByAttribute query = new QueryByAttribute()
    {
        ColumnSet = new ColumnSet(true),
        EntityName = "duplicaterecord"
    };
    query.Attributes.Add("asyncoperationid");
    query.Values.Add(_response.JobId);
    EntityCollection results = _serviceProxy.RetrieveMultiple(query);

    // check to make sure each id is found in the collection
    var duplicateIds = results.Entities.Select((entity) => 
        ((DuplicateRecord)entity).BaseRecordId.Id);
    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",
                id));
        }
    }
    Console.WriteLine("  All accounts detected as duplicates successfully");

    #endregion

    Console.WriteLine();

    DeleteRequiredRecords(promptforDelete);
}

' Connect to the Organization service. 
' The using statement assures that the service proxy will be properly disposed.
_serviceProxy = ServerConnection.GetOrganizationProxy(serverConfig)
Using _serviceProxy
    ' This statement is required to enable early-bound type support.
    _serviceProxy.EnableProxyTypes()

    CreateRequiredRecords()

    ' Create the BulkDetectDuplicatesRequest object
    Console.WriteLine("  Creating the BulkDetectDuplicatesRequest object")
    Dim request As New BulkDetectDuplicatesRequest() With
        {
            .JobName = "Detect Duplicate Accounts",
            .Query = New QueryExpression() With
                     {
                         .EntityName = Account.EntityLogicalName,
                         .ColumnSet = New ColumnSet(True)
                     },
            .RecurrencePattern = String.Empty,
            .RecurrenceStartTime = Date.Now,
            .ToRecipients = New Guid() {},
            .CCRecipients = New Guid() {}
        }

    ' Execute the request
    Console.WriteLine("  Executing BulkDetectDuplicatesRequest")
    _response = CType(_serviceProxy.Execute(request), 
        BulkDetectDuplicatesResponse)

    '                   #Region "check success"

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

    Dim query As New QueryByAttribute() With
        {
            .ColumnSet = New ColumnSet(True),
            .EntityName = "duplicaterecord"
        }
    query.Attributes.Add("asyncoperationid")
    query.Values.Add(_response.JobId)
    Dim results As EntityCollection = _serviceProxy.RetrieveMultiple(query)

    ' check to make sure each id is found in the collection
    Dim duplicateIds = results.Entities.Select(Function(entity) (CType(entity, 
                                                                 DuplicateRecord)).BaseRecordId.Id)
    For Each id In _duplicateAccounts.Select(Function(account) account.Id)
        If Not duplicateIds.Contains(id) Then
            Throw New Exception(String.Format("Account with ID {0} was not detected as a duplicate", id))
        End If
    Next id
    Console.WriteLine("  All accounts detected as duplicates successfully")

    '                   #End Region

    Console.WriteLine()

    DeleteRequiredRecords(promptforDelete)
End Using

Thread Safety

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

See Also

BulkDetectDuplicatesResponse
Microsoft.Crm.Sdk.Messages Namespace
Detect duplicate data
Run duplicate detection
Sample: Detect multiple duplicate records
BulkDetectDuplicates message privileges
How role-based security can be used to control access to entities in Microsoft Dynamics 365
How record-based security can be used to control access to records in Microsoft Dynamics 365

Return to top

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright