Quantcast
Channel: Sam's Activities
Viewing all articles
Browse latest Browse all 3363

Use RetrieveDuplicateRequest in Dynamics CRM

$
0
0

Introduction:

Recently we had a requirement where we had to create Contact records from data received from other System and if Duplicate record found then avoid creation of records based on Duplicate Detection rules specified in the System and get the List of the Duplicate Records found in the system.

The Duplicate Detection rules might be modified or removed whenever needed in future.

We can avoid creation of records using the CreateRequest but as we wanted to get the Duplicate records too we choose the option to use “RetrieveDuplicatesRequest”.

Walkthrough:

We have Published Duplicate Detection rules for Contact in the System by default created for First Name Last Name, Email address and business phone number as you can see below:duplicate detectionIn order to create Contacts using the Duplicate Detection rules we follow below steps:

  • Suppose in System we already have 2 contacts with First Name: Jo and Last Name: Smith
  • Now we received the same data [First Name: Jo, Last Name: Smith] to create Contact in CRM.

So now how we can avoid creation of this record and display the duplicate records information:

Create an Entity object of Contact with all the required attributes as per business requirement firstname and lastname as you can see below:

Entity contactRecord = new Entity("contact");
contactRecord.Attributes["firstname"] = "Jo";
contactRecord.Attributes["lastname"] = "Smith ";
contactRecord.Attributes["emailaddress1"] = "jo@test.com";

After you have created an Entity object pass it to the RetrieveDuplicatesRequest as below:

var request = new RetrieveDuplicatesRequest

{
//Entity Object to be searched with the values filled for the attributes to check
BusinessEntity = contactRecord,

//Logical Name of the Entity to check Matching Entity
MatchingEntityName = contactRecord.LogicalName,


};

var response = (RetrieveDuplicatesResponse)_service.Execute(request);
var request = new RetrieveDuplicatesRequest

{
//Entity Object to be searched with the values filled for the attributes to check
BusinessEntity = contactRecord,

//Logical Name of the Entity to check Matching Entity
MatchingEntityName = contactRecord.LogicalName,

};
var response = (RetrieveDuplicatesResponse)_service.Execute(request);

This request retrieves all the Duplicate records satisfying the Published Duplicate detection rules specified in the system.

response.DuplicateCollection.Entities.Count” will give the Duplicate records count found in the system.

If Zero count found then no duplicate records are found in the System and we can simply create the record.

If greater than Zero count found then we can retrieve the Duplicate records fromresponse.DuplicateCollection.

Conclusion:

The RetrieveDuplicatesRequest can be used for detecting duplicate records found using the Duplicate Detection Rules specified in the System.

You may also like to see : Bing Map license are already part of Maplytics.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Use RetrieveDuplicateRequest in Dynamics CRM appeared first on Inogic Blog.


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>