This documentation is archived and is not being maintained.

RetrieveDuplicates Message (CrmService)

Forefront
banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Works for all deployment typesWorks online only

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

The relevant classes are specified in the following table.

TypeClass
RequestRetrieveDuplicatesRequest
ResponseRetrieveDuplicatesResponse
EntityAny custom or customizable entity that has the EntityMetadata.DuplicateDetection property set to true.

Remarks

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.

Example

The following code example shows how to retrieve duplicates.

[C#]
// 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();
acct.name = "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()
acct.name = "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

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show: