web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Duplicate Detection Plugin

(0) ShareShare
ReportReport
Posted on by 372

I am working on writing a plugin to provide duplicate detection. However, I need to provide a prompt to allow the user to choose whether to create the record or cancel creation. The duplicate criteria is for a incident/case that has the same customer, contact, and was created in the past 36 hours. Unfortunately, there is not way to create a duplicate detection rule that meets that criteria because the only option for created on is "same day" or "same day and time". 

In a pre-validation on create plugin, I use the appropriate logic to detect a duplicate. If I detect a duplicate I throw the following exception that displays the duplicate detected prompt. The problem is the prompt does not show the duplicate record only the original record. Does anyone know how to add the necessary information to the exception so it displays the duplicate records as it should?? 

This is the code I am using to throw the exception:

FaultException<OrganizationServiceFault> ex = new FaultException<OrganizationServiceFault>(new OrganizationServiceFault() { ErrorCode = -2147220685 }, new FaultReason("A record was not created or updated because a duplicate of the current record already exists."));
ex.Detail.Message = "A record was not created or updated because a duplicate of the current record already exists.";


*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Are you using the OOB duplicate detection or your own?

    If you are using your own, then you can use the option of Created On Last 36 hours (as shown in screenshot below).

    CreatedLastXHours.png

    You can't control an exception that much from a client side. If the plugin throws an exception (whether or not you triggered it), this is the result that you are going to get.

    You do have another option.

    Before saving of the record, call an Action that will validate the record being created. You can set in your action return parameters, that will provide the Id of the record that already exists, and display that information to the user.

    You can then display a comparison of the records in your window.

    Hope this helps.

  • ArdantHammer Profile Picture
    372 on at

    Not sure what you mean by using my own duplicate detection, and unfortunately I don't see your screenshot.

    As to the other option, are you saying call the action through javascript? Then use the return parameters within javascript to display any duplicate records to the user. My understanding is javascript is the only way to display data to the user in this fashion.

    Thank you for the help.  

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Added screenshot back.

    Your JavaScript will call the action, which will execute on Server side (like Plugin) and return the results (such as EntityReference), so that you can display the duplicate record to the user.

  • Suggested answer
    prt33k Profile Picture
    6,907 on at

    Hi John,

    Exception in Plugin in a one-way flow, you wont be able to take input from user.

    Interactive check can be made using JS - you can write a script onSave event to check if the record exist and if yes just throw a confirmation box with Ok/Cancel option.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans