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)

Create Contacts if they dont exist yet

(0) ShareShare
ReportReport
Posted on by

Hello everyone.

I want to write a console application that creates Contacts in CRM if the Contacts do not exist yet. And if they exist the Contact shall not be created.

But I dont know how to "Import" the existing contacts to my console application so I can compare the Contacts I want to create to the Contacts that already exist.

Can anyone help me?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Samit Paul Profile Picture
    85 on at

    Instead of Import you need to write logic in your console app to get a contact with primary key (like first name, last name, email etc) from CRM. If you get one record, then the contact exists if NOT write logic to create contact in CRM.

    Hope this resolves your query!!!

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

    Hi,

    Before you build the console application, may I suggest that you take a look at SSIS with Kingswaysoft. You can use that to import the existing contacts into CRM, and you can also use it to import new contacts only by looking (using Lookup Control) at the existing contacts that already exist in CRM.

    Basically if Contact exists - Do Nothing, if Contact doesn't exist - Create New Contact.

    If you still want to use a Console application, you loop through the group of contacts that you want to import, and for each one you check whether the contact already exist in the database. You can do that comparison by retrieving the list of Contacts ahead of time from your CRM org, or by checking for each time whether to contact exists.

    There is plenty of sample code on msdn and the community on how to call Create and RetrieveMultiple records, or using a fetchXml expression that will just return a count of records that match your criteria (in case contacts exist). Basically create the Query to check if Contact exist. If your results has more than zero entities, the Contact already exists in the database.

    Hope this helps.

  • Suggested answer
    Emre GULCAN Profile Picture
    2,379 on at

    Hi,

    You can check "Upsert", msdn.microsoft.com/.../dn932135.aspx

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    You can get existing records from CRM using SDK only, check below sample code from SDK which have sample code for all the methods.

    msdn.microsoft.com/.../dn879513(v=mdm.8).aspx

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans