In the previous post, we saw how we can use the SuppressDuplicateDetection parameter to throw errors in case of duplicates when creating or updating a record.
Here instead of relying on exception, we can make use of the RetrieveDuplicatesRequest message to detect the duplicates.
Let us take the “Leads with the same e-mail address” duplicate detection rule to see it in action.
We can see 3 lead records already existing in the system with the same email address.

Below is our code that is trying to create a new lead record with the same email address and using the RetrieveDuplicatesRequest to check for the duplicates.

Below we can see that not only do we get the total number of duplicates found, but we can also get the details of the duplicate records found.

Get all the details here.
Hope it helps..
Discover more from Nishant Rana's Weblog
Subscribe to get the latest posts sent to your email.

One thought on “Use RetrieveDuplicates request to check for duplicates before creating/updating a record – Dataverse / Dynamics 365”