web
You’re offline. This is a read only version of the page.
close
Skip to main content
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,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

  • Suggested answer
    Preeti Sharma Profile Picture
    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:)

  • CRM Beginner  Profile Picture
    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
    Dynamics365 Rocker Profile Picture
    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
    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?

  • Alex Fun Wei Jie Profile Picture
    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?

  • Verified answer
    Piyush Paliwal Profile Picture
    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.
  • CRM Beginner  Profile Picture
    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
    Alex Fun Wei Jie Profile Picture
    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

  • Piyush Paliwal Profile Picture
    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans