This documentation is archived and is not being maintained.

BulkDetectDuplicates Message (CrmService)

Dynamics
banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Works for all deployment typesWorks online only

Submits an asynchronous duplicates detection job.

The relevant classes are specified in the following table.

TypeClass
RequestBulkDetectDuplicatesRequest
ResponseBulkDetectDuplicatesResponse
EntityAny custom or customizable entity that has the EntityMetadata.DuplicateDetection property set to true.
Optional ParametersRequestIdOptionalParameter

Remarks

To use this message, pass an instance of the BulkDetectDuplicatesRequest class as the request parameter in the Execute method.

An asynchronous duplicates detection job detects duplicate entity instances and logs them as duplicate record entity instances that can be retrieved by using the Retrieve and RetrieveMultiple messages.

Before you use the BulkDetectDuplicates message, make sure that the EntityMetadata.DuplicateDetection property for an entity is set to true and all duplicate detection rules for an entity are published.

To perform this action, the caller must have access rights on the entity instances specified in the request class. For a list of required privileges, see BulkDetectDuplicates Privileges.

Example

The following code example shows how to start a duplicates detection job.

[C#]
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create a query expression for the bulk duplicate detection.
QueryExpression query = new QueryExpression();
query.EntityName = EntityName.account.ToString();

// Create the request (do not send an e-mail).
BulkDetectDuplicatesRequest request = new BulkDetectDuplicatesRequest();
request.JobName = "Detect Duplicate Accounts";
request.Query = query;
request.RecurrencePattern = string.Empty;
request.RecurrenceStartTime = new CrmDateTime();
request.RecurrenceStartTime.Value = DateTime.Now.ToString("s");
request.SendEmailNotification = false;
request.ToRecipients = new Guid[0];
request.CCRecipients = new Guid[0];
request.TemplateId = Guid.Empty;

// Execute the request.
BulkDetectDuplicatesResponse response = (BulkDetectDuplicatesResponse)service.Execute(request);
Guid jobId = response.JobId;
[Visual Basic .NET]
' Set up the CRM Service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create a query expression for the bulk duplicate detection
Dim query As New QueryExpression()
query.EntityName = EntityName.account.ToString()
' Be aware that using AllColumns may adversely affect 
' performance and cause unwanted cascading in subsequent 
' updates.  A best practice is to retrieve the least amount of 
' data required.
query.ColumnSet = New AllColumns()

' Create the request
Dim request As New BulkDetectDuplicatesRequest()
request.JobName = "Detect Duplicate Accounts"
request.Query = query
request.RecurrencePattern = String.Empty
request.RecurrenceStartTime = New CrmDateTime()
request.RecurrenceStartTime.Value = DateTime.Now.ToString("s")

' These properties are REQUIRED: leave blank if no email is needed, otherwise add 
' Customer Id's to the appropriate Guid array
request.ToRecipients = New Guid() {}
request.CCRecipients = New Guid() {}

' Execute the request
Dim response As BulkDetectDuplicatesResponse = CType(service.Execute(request), BulkDetectDuplicatesResponse)
Dim jobId As Guid = response.JobId

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show: