Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Create Contacts if they dont exist yet

    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

  • Suggested answer
    Emre GULCAN Profile Picture
    Emre GULCAN 2,379 on at
    RE: Create Contacts if they dont exist yet

    Hi,

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

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 Moderator on at
    RE: Create Contacts if they dont exist yet

    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
    Samit Paul Profile Picture
    Samit Paul 85 on at
    RE: Create Contacts if they dont exist yet

    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!!!

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans