Migrate data from a legacy system into Dynamics 365
Introduction
This post steps through the migration of data from a legacy system (the legacy data being extracted into spreadsheets) and into a Dynamics 365 environment. Specifically the migration of contacts, including their residential addresses
Note: This is an example of a small migration. For a larger migration, I would consider setting up staging tables rather than using spreadsheets. These tables would mirror the structure of the Dynamics 365 / Dataverse tables
Steps to migrate data into Dynamics 365
Generate empty spreadsheets
1.) Within Dynamics 365, click on Settings, Data Management (Figure 1)
![](https://dustinminer.com/wp-content/uploads/2021/06/1-5.png)
2.) Next, click on ‘Imports’ (Figure 2)
![](https://dustinminer.com/wp-content/uploads/2021/06/2-3.png)
3.) Export the Contact and Address tables into two spreadsheet templates (Figure 3)
![](https://dustinminer.com/wp-content/uploads/2021/06/3-3.png)
4.) Clear any data contained in the spreadsheets (Figure 4)
![](https://dustinminer.com/wp-content/uploads/2021/06/4-4.png)
Populate the spreadsheets
5.) Cleanse and apply uniform formatting to the legacy data displayed in Figure 5. For example, ensure the formatting of the ‘Date of Birth’ in each record matches
![](https://dustinminer.com/wp-content/uploads/2021/06/5-5.png)
6.) Copy the cleansed legacy data into the ‘Contact’ & ‘Address’ spreadsheets created in the previous section.
(Although not shown in this example, if the ‘created on’ date for each legacy record needs to be maintained, map this value to the Dataverse column ‘Record Created On’ (logical name overriddencreatedon). The value placed here will be written to the Dataverse column ‘Created on’ during the data import process.)
7.) Take the ‘Address’ spreadsheet (Figure 6) an ensure each address is unique by highlighting the cells in ‘Street 1’ column, selecting ‘Conditional Formatting’, ‘Highlight Cell Rules’ and finally selecting ‘Duplicate Values’.
![](https://dustinminer.com/wp-content/uploads/2021/06/6-4.png)
8.) Create a column called ‘AddressRef’ which will be used to link the ‘Address’ spreadsheet to the ‘Contact’ spreadsheet
9.) Take the ‘Contact’ spreadsheet and create a VLOOKUP to the address spreadsheet. Also, link the Contact spreadsheet to the Address spreadsheet via the column ‘Primary Address Lookup’
![](https://dustinminer.com/wp-content/uploads/2021/06/7-1.png)
10.) Ensure that the Option set & Owner columns within the spreadsheets contain values that already exist in the Dynamics 365 environment. Otherwise the import of that particular spreadsheet would fail.
11.) Place the spreadsheets on OneDrive in order for them to be shared securely and have their version history maintained. (I needed to set the spreadsheet on One Drive to Region – Australia to resolve issues I was having with dates. That is, some date values where showing in Australian format whilst others were shown in US format.)
Import the data into Dynamics 365
12.) Import the Address spreadsheet into Dynamics 365
13.) Then import the Contact spreadsheet making sure to set the lookup reference (Figure 8)
![](https://dustinminer.com/wp-content/uploads/2021/06/8.png)
Note: an active plugin or workflow may stop data being imported (Figure 9). An example of this is trying to import invoices when the corresponding mandatory orders don’t yet exist. That is, when a new invoice is created, the plugin/workflow tries to retrieve the corresponding order to perform some logic
![](https://dustinminer.com/wp-content/uploads/2021/06/9.png)
Appendix
Updating Business Process Flows (BPFs)
Migrated tables that contain a business process flow may need that flow updated after the migration. Referring to Figure 10, the BPF needs to be placed in the ‘complete’ state.
![](https://dustinminer.com/wp-content/uploads/2021/06/10.png)
To place all the relevant BPFs in the complete state, follow these steps
- Use the XrmToolBox BPF plugin to perform a bulk move from the stage ‘Preparation’ to ‘Send For Approval’
- In the ‘Form’ entity, perform a build set of the field ‘Approval Requested To’
- For the BPF entity, update
- ‘Completed On’ to current date
- ‘Status Reason’ to finished
- ‘Status’ to inactive
Prepare legacy data to be imported into Dynamics 365
The example shown in Figure 5 takes legacy data from one legacy database table and maps it to two Dynamics 365 tables. This example takes two legacy database tables (Figure 11 & 12) and consolidates them into one Dynamics 365 table
![](https://dustinminer.com/wp-content/uploads/2021/06/11.png)
![](https://dustinminer.com/wp-content/uploads/2021/06/12-1.png)
The following SQL retrieves the data from the two legacy tables and maps them to the columns of a Dynamics 365 table (Figure 13)
![](https://dustinminer.com/wp-content/uploads/2021/03/SQL-1-2.png)
![](https://dustinminer.com/wp-content/uploads/2021/06/13.png)
The result set is then placed into a spreadsheet which can then be imported into the Dynamics 365 environment
Further reading
Maintain the same guids in Dynamics 365 environments
References
https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1