{"id":5145,"date":"2016-12-19T20:29:38","date_gmt":"2016-12-19T20:29:38","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/premier_developer\/?p=5145"},"modified":"2019-02-14T20:27:47","modified_gmt":"2019-02-15T03:27:47","slug":"how-to-import-related-data-into-dynamics-365","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/how-to-import-related-data-into-dynamics-365\/","title":{"rendered":"How to Import Related Data into Dynamics 365"},"content":{"rendered":"<p>In this post, Senior ADM <a href=\"https:\/\/www.linkedin.com\/in\/jmscotty\">Justin Scott<\/a> walks us through how to maintain entity\/table relationships when importing data into Dynamics 365.<\/p>\n<hr width=\"100%\" size=\"1\" align=\"center\" \/>\n<p>A recent project I was on involved bringing over customer and contact information from another proprietary CRM application. Being newer to the Dynamics platform, one challenge was to figure out how to maintain the relationships between two related tables (tables are known as \u201centities\u201d in Dynamics 365), such as the case we had here between Companies and Contacts. In the application that we were importing data from, there was a 1:N foreign key relationship between the companies and contacts. This meant that each company can have many contacts, and each contact could belong to one company as shown in the ERD diagram below:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics1.png\"><img decoding=\"async\" width=\"644\" height=\"81\" title=\"dynamics1\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" alt=\"dynamics1\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics1_thumb.png\" border=\"0\" \/><\/a><\/p>\n<p>You can use this relationship during the import, but afterwards, this same foreign key concept would not make sense considering Dynamics 365 takes care of entity relationships without the need to maintain your own foreign keys.\u00a0 Below I shared the steps needed to import the Companies and Contacts while keeping the relationships. The key concept is to map the foreign key just for importing purposes, and then let the system maintain the relationships going forward.<\/p>\n<h2><b>1. <\/b><b>Get the data needed to be imported into csv files<\/b><\/h2>\n<p><strong>\u00a0\u00a0 a.<\/strong> Export Company table data into an excel file including its primary key as a column.\n<strong>\u00a0\u00a0 b.<\/strong> Export Contact info into a second excel file, being sure to include the foreign key column that references the Company key column.\n<strong>\u00a0\u00a0 c.<\/strong> Be sure that both files have their column names as the first row of the files.\n<strong>\u00a0\u00a0 d.<\/strong> Save the Company and Contact files as separate comma-separated values (csv) files after all data grooming is complete.<\/p>\n<h2><b>2. <\/b><b>Open the Dynamics 365 Import Wizard<\/b><\/h2>\n<p><strong>\u00a0\u00a0 a.<\/strong> If you don\u2019t already have a Dynamics 365 account, you can sign up for a free trial <a href=\"https:\/\/signup.microsoft.com\/Signup?OfferId=bd569279-37f5-4f5c-99d0-425873bb9a4b&amp;dl=DYN365_ENTERPRISE_PLAN1&amp;Culture=en-us&amp;Country=us&amp;flight=AdminOnCustomization&amp;ali=1\">here<\/a>.\n<strong>\u00a0\u00a0 b.<\/strong> Once logged into Dynamics 365, go to the import wizard by going to <b>Settings<\/b> &gt; <b>Data Management<\/b> from the main CRM Dynamics home screen\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics2.png\"><img decoding=\"async\" width=\"644\" height=\"247\" title=\"dynamics2\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" alt=\"dynamics2\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics2_thumb.png\" border=\"0\" \/><\/a>\n<strong>\u00a0\u00a0 c.<\/strong> Choose Imports from the Data Management form\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics31.png\"><img decoding=\"async\" width=\"224\" height=\"46\" title=\"dynamics3\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px\" alt=\"dynamics3\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics3_thumb1.png\" border=\"0\" \/><\/a>\n<strong>\u00a0\u00a0 d.<\/strong> Select the Import Data link at the top of the Imports form\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics41.png\"><img decoding=\"async\" width=\"224\" height=\"59\" title=\"dynamics4\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" alt=\"dynamics4\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics4_thumb1.png\" border=\"0\" \/><\/a>\n<b><\/b><\/p>\n<h2><b>3. <\/b><b>Import your Contact records<\/b><\/h2>\n<p><strong>\u00a0\u00a0 a.<\/strong> Since the contact records will have a column that links to the company records, we must import the company records first. Browse to your Company csv file you created.<\/p>\n<p><strong>\u00a0\u00a0 b.<\/strong> For the Company data, I decided to utilize the existing \u201cAccount\u201d entity since it holds company-type information. Since I was using an existing entity, I need to choose one of the system data maps to make it easier to map fields:\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics5.png\"><img decoding=\"async\" width=\"644\" height=\"431\" title=\"dynamics5\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" alt=\"dynamics5\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics5_thumb.png\" border=\"0\" \/><\/a>\n<strong>\u00a0\u00a0 c.<\/strong> You will need to go through each field in your import file and map it to a field in Dynamics 365.\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics6.png\"><img decoding=\"async\" width=\"644\" height=\"693\" title=\"dynamics6\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" alt=\"dynamics6\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics6_thumb.png\" border=\"0\" \/><\/a><\/p>\n<p><strong>\u00a0\u00a0 d.<\/strong> The <b>Required Fields<\/b> section is looking for the main user-friendly way to identify the record. In our case, we would map the Company name to the existing <b>Account Name<\/b> field.<\/p>\n<p><strong>\u00a0\u00a0 e.<\/strong> Any new fields that can be added by selecting <b>Create New Field<\/b> and then choosing what datatype it is.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics71.png\"><img decoding=\"async\" width=\"324\" height=\"157\" title=\"dynamics7\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px\" alt=\"dynamics7\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics7_thumb1.png\" border=\"0\" \/><\/a><\/p>\n<p><strong>\u00a0\u00a0 Note:<\/strong> There are only a few datatypes to choose from when using the import wizard, and the field data type cannot be changed later. The data types available are shown below:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics8.png\"><img decoding=\"async\" width=\"654\" height=\"269\" title=\"dynamics8\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" alt=\"dynamics8\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics8_thumb.png\" border=\"0\" \/><\/a><\/p>\n<p><strong>\u00a0\u00a0 f.<\/strong> After all mappings are complete, select <b>Next<\/b> to begin the import. A job is then submitted to begin the import process. This job can take a while to run, but you can view the progress and status of the run in the <b>My Imports<\/b> section as shown below. This area will also show you if any errors occurred during the import.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics9.png\"><img decoding=\"async\" width=\"644\" height=\"105\" title=\"dynamics9\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" alt=\"dynamics9\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics9_thumb.png\" border=\"0\" \/><\/a><\/p>\n<p>Selecting the file name will give you additional details including information about any import errors that occurred.<\/p>\n<h2><strong>4.<\/strong> <b>Import your Contact records<\/b><\/h2>\n<p><strong>\u00a0\u00a0 a.<\/strong> See step 2 for how to open the import wizard.<\/p>\n<p><strong>\u00a0\u00a0 b.<\/strong> Once in the import wizard, browse to your Contact csv file you created.<\/p>\n<p><strong>\u00a0\u00a0 c.<\/strong> For the Contact data, I utilized the existing \u201cContact\u201d entity. Since I was using an existing entity, I need to choose one of the system data maps to make it easier to map fields:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics10.png\"><img decoding=\"async\" width=\"644\" height=\"431\" title=\"dynamics10\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" alt=\"dynamics10\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics10_thumb.png\" border=\"0\" \/><\/a><\/p>\n<p><strong>\u00a0\u00a0 d.<\/strong> You will need to go through each field in your import file and map it to a row in Dynamics 365.<\/p>\n<p><strong>\u00a0\u00a0 e.<\/strong> The key difference between the overall process of uploading Company verses contact records is that we want to define a field in Contacts that helps us link the contacts to the companies upon doing the import. To do this, we need to map the foreign key given to us by the source system. In the import dialog, the <b>Type<\/b> should be set to <b>Lookup<\/b>, the <b>Related Record Type<\/b> should be set to the entity to relate to (in this case Company), and the <b>Referred Field<\/b> should be set to the field that will match the foreign key (in this case ID) being imported as shown below.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics111.png\"><img decoding=\"async\" width=\"324\" height=\"175\" title=\"dynamics11\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px\" alt=\"dynamics11\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/dynamics11_thumb1.png\" border=\"0\" \/><\/a><\/p>\n<p><strong>\u00a0\u00a0 Note:<\/strong> The imported contact data had a column called <b>LINK_COMP_ID<\/b> that was a foreign key in the source system to the field named <b>ID<\/b> in the Company Entity that has already had its data imported.<\/p>\n<h2><b>Summary<\/b><\/h2>\n<p>In the steps above we showed you how to take related data from another application and maintain that relationship when importing the data into the Dynamics 365. When doing this, Dynamics is designed to understand that you only need this mapping for the import and that after the import, this foreign key relationship will be maintained internally. In other words, you could drop the key and foreign key columns after all the imports were completed, and the relationships would still exist. Taking it a step further, having these relationships in the system sets you up nicely for creating a company form that has all the related company contacts listed on the same form.<\/p>\n<hr \/>\n<p><a href=\"https:\/\/blogs.msdn.microsoft.com\/b\/premier_developer\/archive\/2014\/09\/15\/welcome.aspx\"><strong>Premier Support for Developers<\/strong><\/a> provides strategic technology guidance, critical support coverage, and a range of essential services to help teams optimize development lifecycles and improve software quality.\u00a0 Contact your Application Development Manager (ADM) or <a href=\"https:\/\/blogs.msdn.microsoft.com\/premier_developer\/contact-us\/\">email us<\/a> to learn more about what we can do for you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, Senior ADM Justin Scott walks us through how to maintain entity\/table relationships when importing data into Dynamics 365. A recent project I was on involved bringing over customer and contact information from another proprietary CRM application. Being newer to the Dynamics platform, one challenge was to figure out how to maintain the [&hellip;]<\/p>\n","protected":false},"author":582,"featured_media":37840,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[3],"class_list":["post-5145","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-permierdev","tag-team"],"acf":[],"blog_post_summary":"<p>In this post, Senior ADM Justin Scott walks us through how to maintain entity\/table relationships when importing data into Dynamics 365. A recent project I was on involved bringing over customer and contact information from another proprietary CRM application. Being newer to the Dynamics platform, one challenge was to figure out how to maintain the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/5145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=5145"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/5145\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/37840"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=5145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=5145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=5145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}