We can make use SuppressDuplicateDetection optional parameter of the Request if we want the configured duplicate detection rules to run and throw an exception while creating or updating the record.
We will use the below out-of-the-box duplicate detection rule, that checks for lead having same email address.

Below is our code and we can see the lead records with the same email address getting created without any exception.


Now we have updated the code to use the SuppressDuplicateDetection optional parameter. We have set it as false.

As expected this time we get the exception.
“The record was not created or updated because a duplicate of the current record already exists.”
Hope it helps..
Discover more from Nishant Rana's Weblog
Subscribe to get the latest posts sent to your email.

One thought on “Use SuppressDuplicateDetection parameter of Request to throw an exception in case of duplicates – Dataverse / Dynamics 365”