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)

Best Practice to prevent duplicate record in crm 365

(0) ShareShare
ReportReport
Posted on by 195

Hi, I have a question, I want to prevent record in my entity to be duplicated actually, I already create a plugin that runs on pre-operation it's working but its buggy. Why its buggy? because when the record is created at the same time when I said the same time the difference between the creation of one record with another is only a matter of a millisecond. So when both are checking if the record with the same name is already created or not it will return false. I come with a solution to make my plugin runs on post-operation and make it asynchronous, but it will delete both records instead. Any suggestion for this? Thanks in advance 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Rawish Kumar Profile Picture
    13,758 on at

    Hello there,

    For preventing duplicate record creation - you should be able to use alternate keys in dynamics crm.

    have a look here : docs.microsoft.com/.../define-alternate-keys-entity

    you can have upto 5 alternate keys for the entity and in each alternate key you can have multiple fields within.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    In addition you can also register your plugin on pre-validation (Synchronous) and return exception.

  • Mansoor Sulaiman Profile Picture
    4,330 on at

    Is there any specific reason not to use OOB duplicate detection rules?

    Mansoor

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Duplicate detection rules will warn you with duplicate records , but you can create and not prevent you to create.

  • Keysersozeey Profile Picture
    195 on at

    @Rawish Kumar

    Hi,

    Thanks for your answer i will look forward to it

  • Community Member Profile Picture
    on at

    Soooo I have configured an Alternate key using only the name field (text) but the records in this particular entity are created by a workflow. The duplicates are still creating. My research is indicating that neither duplicate detection or alternate keys stop a workflow from creating records. Is this true? Is there anything else or any suggestions ANYONE can offer me? We are completely native.

  • Suggested answer
    crm development Profile Picture
    870 on at

    Hi Merry, As suggested earlier, write a Plugin on pre create of record. Check duplicate record and throw an exception. This will prevent from duplicate creation.

    Thanks,

    Anand

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    Hi Merry,

    An alternate key is essentially created at the database level which signifies that from no matter where a record is getting created i.e manual, import, workflow, plugin , integration etc. the alternate key will be enforced.

    When you created the alternate key - the job was successful? I am referring to this : passion4dynamics.com/.../alternate-key-creation-stuck-on-pending-status  

  • Jag S Profile Picture
    214 on at

    Hi Keysersozeey,

    Did you find a solution as I have a similar issue.

    Thanks,

    Jag

  • Community Member Profile Picture
    on at

    In my case there were three different criteria in the workflow and the workflow kept triggering on a different one of the three and created duplicates. I tried the alternate key as well as a duplicate detection rule and those did not prevent duplicates. I created a business rule that evaluated for the various combinations of the three criteria and then added a simple yes no field on The entity and used to that in the workflow. I was able to stop the duplicates because once the value is yes the workflow no longer triggered.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight 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