{"id":2055,"date":"2015-11-25T14:58:38","date_gmt":"2015-11-25T09:28:38","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=2055"},"modified":"2026-02-09T12:43:19","modified_gmt":"2026-02-09T07:13:19","slug":"use-retrieveduplicaterequest-in-dynamics-crm","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2015\/11\/use-retrieveduplicaterequest-in-dynamics-crm\/","title":{"rendered":"Use RetrieveDuplicateRequest in Dynamics CRM"},"content":{"rendered":"<p><a href=\"https:\/\/bit.ly\/44YA8tv\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"alignnone size-full wp-image-35682\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/05\/DeDupeD.gif\" alt=\"DeDupeD\" width=\"700\" height=\"200\" \/><\/a><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Introduction:<\/strong><\/span><\/p>\n<p>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.<\/p>\n<p>The Duplicate Detection rules might be modified or removed whenever needed in future.<\/p>\n<p>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 \u201cRetrieveDuplicatesRequest\u201d.<\/p>\n<p><strong>Walkthrough:<\/strong><\/p>\n<p>We have <strong>Published<\/strong> 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:<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/11\/duplicate-detection.png\"><img decoding=\"async\" class=\"aligncenter wp-image-2056 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/11\/duplicate-detection.png\" alt=\"duplicate detection rule\" width=\"630\" height=\"288\" \/><\/a>In order to create Contacts using the Duplicate Detection rules we follow below steps:<\/p>\n<ul>\n<li>Suppose in System we already have 2 contacts with First Name: Jo and Last Name: Smith<\/li>\n<li>Now we received the same data [First Name: Jo, Last Name: Smith] to create Contact in CRM.<\/li>\n<\/ul>\n<p>So now how we can avoid creation of this record and display the duplicate records information:<\/p>\n<p>Create an Entity object of Contact with all the required attributes as per business requirement firstname and lastname as you can see below:<\/p>\n<pre class=\"lang:default decode:true \">Entity contactRecord = new Entity(\"contact\");\r\n\r\n       contactRecord.Attributes[\"firstname\"] = \"Jo\";\r\n\r\ncontactRecord.Attributes[\"lastname\"] = \"Smith \";\r\n\r\ncontactRecord.Attributes[\"emailaddress1\"] = \"jo@test.com\";\r\n<\/pre>\n<p>After you have created an Entity object pass it to the RetrieveDuplicatesRequest as below:<\/p>\n<pre class=\"lang:default decode:true \">var request = new RetrieveDuplicatesRequest\r\n\r\n                {\r\n\/\/Entity Object to be searched with the values filled for the attributes to check\r\n                    BusinessEntity = contactRecord,\r\n                   \r\n\/\/Logical Name of the Entity to check Matching Entity\r\n   MatchingEntityName = contactRecord.LogicalName,\r\n\r\n                    \r\n                };\r\n\r\n                var response = (RetrieveDuplicatesResponse)_service.Execute(request);\r\n<\/pre>\n<p>This request retrieves all the Duplicate records satisfying the <strong>Published<\/strong> Duplicate detection rules specified in the system.<\/p>\n<p>\u201c<strong>response.DuplicateCollection.Entities.Count<\/strong>\u201d will give the Duplicate records count found in the system.<\/p>\n<p>If <strong>Zero<\/strong> count found then no duplicate records are found in the System and we can simply create the record.<\/p>\n<p>If greater than Zero count found then we can retrieve the Duplicate records from <strong>response.DuplicateCollection.<\/strong><\/p>\n<p><strong>Conclusion:<\/strong><\/p>\n<p>The RetrieveDuplicatesRequest can be used for detecting duplicate records found using the Duplicate Detection Rules specified in the System.<\/p>\n<p>You may also like to see : Bing Map license are already part of <a href=\"http:\/\/inogic.com\/Product\/76\/Integrations\/Maplytics\" target=\"_blank\" rel=\"noopener noreferrer\">Maplytics<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2015\/11\/use-retrieveduplicaterequest-in-dynamics-crm\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[15,19,22,24,42],"tags":[1475],"class_list":["post-2055","post","type-post","status-publish","format-standard","hentry","category-development","category-dynamics-crm","category-dynamics-crm-2015","category-dynamics-crm-2016","category-plugin","tag-retriveduplicaterequest"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/2055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=2055"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/2055\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=2055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=2055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=2055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}