This article is a continuation of the discussion about the new workspace called Data Management in Microsoft Dynamics 365 for Operations (MsDyn365). Data Management replaces the Data Import and Export Framework (DIXF) Module that was available in AX 2012 R2 and above. This illustrates the real world process of creating new tables for legacy or new processes and being able to populate that table using the expanded data management tool.
The emphasis of this article is to introduce you to the technical process of creating a data entity that you can use for both the import and export of data. This is the version where we create a data entity from a table versus creating the data entity via the wizard.
To demonstrate this life cycle, we will create a table, generate a data entity, export the headers, insert data, and then import it back into Microsoft Dynamics 365. The assumption of this article is that you created a package, model, and project to contain your programming within Visual Studio in your own virtual image or Azure-hosted development environment. Ensure that your model has an association to the Fleet Management package. Please see Development Basics in Customer Source, or subscribe to our training sessions on basic programming if you are unfamiliar with this process.
Data Management in Dynamics 365: Creating a Data Entity from a Table
Create the Table
For the first operation, we will need to create the table to use as the basis for the data entity. Any table will work; for simplicity, we are creating one for this exercise. In this case, we used the Demo Dynamics 365 for Operations November 2016 release (previous versions will also work).
To Create the Table:
- Open Visual Studio as an administrator and create a package, model, and project to contain your objects.
- Right click your project, and click New > Add item.
- Select Data Model > Table.
- Enter rsmRentalVehicleTable for the name, and click Add.
- In the Application Explorer, drag and drop the following Extended Data types from the Data Types node. Once inserted, change the names and the labels to the following.
- Note: On the RANumber, ensure that property Allow Edit is set to No.
|Extended Data Type
|Rental Start Date
- Create the following new fields by right-clicking Fields and selecting New.
|Primitive Data Type
|Number of Days
- Save all the new fields.
- Expand the Indexes node and right-click for New Index.
- Rename by right clicking and Rename to RANumberIdx
- Drag RANumber from the Fields node to the newly created Index.
- Save all.
- Right-click the rsmRentalVehicleTable.
- Enter Rental Vehicle in the Label
- Set the Primary Index to the newly created RANumberIdx.
- Save all and then click Build.
- Ensure that there are no errors. If you have an error resolve and rebuild.
Create the Data Entity
In this part of the process, we are generating the data entity. It not only creates a data entity, it also creates the staging table and security privileges needed for the entity use.
To create the data entity, follow these steps:
- Select the correct project in the Solution Explorer.
- In the center code editor, right-click the newly created rsmRentalVehicleTable.
- Click Addins > Create data entity.
Create Data Entity
- Click OK.
- Save all and click Build. Ensure that there are no errors. If you have an error resolve and rebuild.
- Synchronize the project in order to ensure database integrity if you don’t already synchronize on project in your Visual Studio settings.
Exporting and Updating the Data Set
Exporting the Data Header
For the second major operation, you will update the information on the Excel spreadsheet so that you can reimport. The emphasis here is to not change any of the columns because these are exactly what the format will be on the import. If you were to change the columns, they you would need to use a different data entity or remap that entity to work.
To export the data header, follow these steps:
- Open Dynamics 365 for Operations and then click Show navigation pane.
- Under Workspaces, open Data Management.
- Click the Export
- Enter rsmRentalVehicleHeaderExport.
- Select Excel for in the Target Data Format
- Select or enter rsmRentalVehicleTableEntity in the Entity name
- Ensure that the Skip staging field is set to Yes.
- Select Yes in the Generate data package
- Select the rsmRentalVehicleHeaderExport.
- Click Download in the action pane.
- Click Open.
- Copy the rsmRentalVehicleTableEntity Excel file to the desktop (or another easily accessible location).
Update the Data Set
For this step, we will update the information on the Excel spreadsheet so that we can reimport. Again, the emphasis here is to not change any of the columns because these are exactly what the format will be on the import. If you were to change the columns, you would need to use a different data entity or remap that entity to work.
To update the data set, follow these steps:
- Open the file xlsx from your desktop, if not already displayed.
- Click Enable Editing, if displayed.
- Enter new information on the spreadsheet, paying special attention to key fields so that you have unique values for like RANumbers.
- Repeat step 2 (the creation of new customers) so you have at least 7 new entries.
- Save and close the spreadsheet.
Importing the Data Set in to Dynamics 365
For the third major operation, we will import the data back in to Dynamics 365. Since we created the data entity specifically for this operation, we have a perfect data set match. Not all mappings will occur this way and we will delve into complex data set imports in a future article.
To import the modified data set, follow these steps:
- Open Dynamics 365 for Operations and click Show navigation pane.
- Under Workspaces, Open Data Management
- Click the Import
- Enter rsmRentalVehicleImport in the Name
- Select Excel in the Source data format
- Select rsmRentalVehicleTableEntity in the Entity name
- Click Upload.
- Select rsmRentalVehicleTableEntity and then click Open.
- Select Sheet1$ (or name of sheet in your Excel item) in the Sheet lookup
- Click Yes to generate the mapping from scratch.
- Click View map.
- This should have mapped exactly. If not, map accordingly if there were any changes.
- Close the form.
- Click Import on the action pane.
- Click View staging data to see imported items.
- Click Copy data to target.
- Click OK.
- Click Run.
To check the import of the data set, follow these steps:
- Open Visual Studio as an administrator.
- Select the rsmRentalVehicleTable and click Open.
- Right-click the table and select Table Browser.
- Log in, if necessary.
- Validate that the data was imported.
This article reviewed the Data Management Data Entity creation and use. We created a table and generated a data entity, changed the data set to simulate the update process, and covered the import process. We also covered the complete lifecycle of Data Management and a custom data entity to illustrate that you can populate new table structures quickly and effectively using these tools. In addition, the potential for your use of these process in your operation expand the ability to automate data updates that range from very simple to complex.
For more information, I would recommend “Data entities and packages framework” on the ax.help.dynamics.com, our Dynamics 365 live training, or our on-demand online training to learn more. Plus, keep an eye out for more articles that dive into the technical aspects of using the data management and SQL.
Please visit academy.rsmus.com for more information and training materials that will cover this and hundreds of other topics for AX2012 and Dynamics 365! Or contact our dynamics pros experts. 855-437-7201