RetrieveDuplicates Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Works for all deployment types Works online only

Detects and retrieves duplicate entity instances for a specified entity instance.

The relevant classes are specified in the following table.

Type Class
Request RetrieveDuplicatesRequest
Response RetrieveDuplicatesResponse
Entity Any custom or customizable entity that has the EntityMetadata.DuplicateDetection property set to true.


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

Before you use the RetrieveDuplicates 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 RetrieveDuplicates Privileges.


The following code example shows how to retrieve duplicates.

// Set up the CRM service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
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 the account instance and set the name property.
account acct = new account(); = "Microsoft";

// Create the request object.
RetrieveDuplicatesRequest Request = new RetrieveDuplicatesRequest();
Request.BusinessEntity = acct;
Request.MatchingEntityName = EntityName.account.ToString();
Request.PagingInfo = new PagingInfo();

// Execute the request.
RetrieveDuplicatesResponse Response = 
    (RetrieveDuplicatesResponse) Service.Execute(Request);

[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 an account instance.  
Dim acct As New account() = "Microsoft"

' Create a RetrieveDuplicates request.
Dim Request As New RetrieveDuplicatesRequest()
Request.BusinessEntity = acct
Request.MatchingEntityName = EntityName.account.ToString()
Request.PagingInfo = New PagingInfo()

' Retrieve the duplicates.
Dim Response As RetrieveDuplicatesResponse = CType(Service.Execute(Request), RetrieveDuplicatesResponse)

See Also



© 2010 Microsoft Corporation. All rights reserved.