Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Preventing Duplicate Contact Creation of incremental run of CRM Data

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

  • Piyush Paliwal Profile Picture
    Piyush Paliwal 817 on at
    RE: Preventing Duplicate Contact Creation of incremental run of CRM Data

    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.

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Preventing Duplicate Contact Creation of incremental run of CRM Data

    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

  • CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Preventing Duplicate Contact Creation of incremental run of CRM Data

    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
    Piyush Paliwal Profile Picture
    Piyush Paliwal 817 on at
    RE: Preventing Duplicate Contact Creation of incremental run of CRM Data

    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.
  • Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Preventing Duplicate Contact Creation of incremental run of CRM Data

    Hi,

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

  • CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Preventing Duplicate Contact Creation of incremental run of CRM Data

    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?

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Preventing Duplicate Contact Creation of incremental run of CRM Data

    Hi,

    Why are you not using Duplicate detection rule?

  • CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Preventing Duplicate Contact Creation of incremental run of CRM Data

    Hi,

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

  • Suggested answer
    Preeti Sharma Profile Picture
    Preeti Sharma 2,678 on at
    RE: Preventing Duplicate Contact Creation of incremental run of CRM Data

    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:)

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Preventing Duplicate Contact Creation of incremental run of CRM Data

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans