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)

Preventing Duplicate Contact Creation of incremental run of CRM Data

(0) ShareShare
ReportReport
Posted on by 795

Hi,

I am working on removing duplicates from CRM. I have worked on deactivating duplicate records having same email address. And created a table in Database storing inactive customer's id mapped to GoldenCustomer's id. Now, i want to write a plugin in which i want if next time duplicate record comes in incremental, it will fetch data from this stored table and won't create a new record. 

Any suggestions on how to proceed with this approach?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    you can create a plugin and trigger on that entity record creation or update,  apply you checking logic, and throw some meaningful error message to user once criteria is met.

    docs.microsoft.com/.../use-invalidpluginexecutionexception-plugin-workflow-activities

  • Suggested answer
    Preeti Sharma Profile Picture
    2,678 on at

    Hi,

    If you are looking for solution to update a record if it already exists rather than creating a new record, then you can use Upsert request in your plugin.

    Following links may be helpful to you for same:

    1. docs.microsoft.com/.../use-upsert-insert-update-record

    2. community.dynamics.com/.../upsert-request-using-alternative-key

    3. docs.microsoft.com/.../sample-insert-update-record-upsert

    Hope this helps:)

  • CRM Beginner Profile Picture
    795 on at

    Hi,

    Can you suggest me is it possible to deploy a plugin on create and update of 3-4 entities?

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    7,755 on at

    Hi,

    Why are you not using Duplicate detection rule?

  • CRM Beginner Profile Picture
    795 on at

    No, my requirement is somewhat different..I am at last step where i need to write a plugin and then update a lookup field of all child records of a customer entity on create / update..That's why i am asking..can i do it for more than one entity?

  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    what do you means by can i do it for more than one entity?

  • Verified answer
    Piyush Paliwal Profile Picture
    817 on at

    with this, if you mean that you want to fire the same plugin on multiple entities then yes you could do that.

    1. Create different SDK processing steps for all the entities where you want this plugin to fire
    2. In your plugin code have a switch statement based on the entity logical name present in the context's target.
    3. Perform the necessary logic.
  • CRM Beginner Profile Picture
    795 on at

    Thanks Piyush.

    This is exactly what i was asking for.. Stuck in one more sitution, Can i integrate SQL Server with Plugin? Or i mean can i access external SQL Database with Plugin code?

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    For SQL and plugin , you can refer below article. 

    blogs.msdn.microsoft.com/.../accessing-a-sql-database-from-a-microsoft-dynamics-crm-plug-in

    But you are using CRM online, you cant do that, so you have to create a web service to achieve that.

    community.dynamics.com/.../171481

  • Piyush Paliwal Profile Picture
    817 on at

    Yes you can. Refer to the article that @Wei shared, however I would rather suggest you against it. You should create a web service/API which interacts securely with SQL Database and from your plugin code you should fire up methods from this service.

    Let me reiterate, I would highly recommend not interacting with SQL directly from within your plugin code.

    PS: Please close the thread with a verified answer if the responses here helped you resolving the issue.

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