How To

Creating and Importing Data into Custom Entities in Dynamics 365

In this guide we are going to cover creating a custom entity in Dynamics, and then how you can synchronise data to this using Data Synchronisation Studio.

Requirements

Before getting started you need to ensure you have the following:

Create a Custom Entity in Dynamics 365

To create custom entities in Dynamics 365 you need to use the power platform admin center and go to Objects > Tables > New Table

Enter in a display name, plural name, and description for the entity (now known as tables) and click Save to create your entity.

Create a Custom Entity in Dynamics

Here we have created a supplier entity to hold the details about the suppliers of each product listed in Dynamics. By expanding the Advanced Options we can further customise the settings for this new entity.

Supplier Custom Entity

Once you click Save this will open the supplier table properties view. Under Schema click onto Columns to add columns (fields) to the entity as required.

Add Columns

Once you are in the columns view add columns by clicking onto New column. In this entity we have added an external identifier, various address columns, and a lookup column to contact.

Custom Entity

To make the new entity visible in the Dynamics App you need to back to the main power app admin center home, and then go to Apps and select the app you want to add the entity to. In this example we need to add it to the Customer Service Hub, so we select this and then go to Edit.

Edit App

You then need to click onto Add Page > Select a page type (Table based view and form) > Next > Search for the entity i.e. Suppliers and then click Add.

Add Entity to Dynamics View

To publish the results click Save and then Publish. Once this is done you can navigate to your Dynamics site and view the entity. If it is not showing in the navigation you may need to do a hard refresh of the page (CTRL + F5).

Connect to Source Data and Dynamics Entity

For this example we are going to load the suppliers table from a SQL Database into the new suppliers entity in Dynamics. So we need to connect the source window to this suppliers table.

A sample of the data set we will be using can be seen here:

Source Data Preview

The connection to this Database has already been saved to the connection library so we can simply expand the connection, and drag and drop the suppliers table onto the source window. For detailed guidance on creating a connection to a SQL table please take a look at our documentation

We then need to connect the target to our custom entity, Suppliers. To do this go to the connection library window and expand your Dynamics connection. Look for the new entity (usually starts new_) and then right click and select Connect to Target (B).

Connect to Dynamics

This sets your custom entity as the target in Data Sync. If you have not yet configured and saved your connection to your Dynamics site you can learn how to do so in our documentation pages here.

Lookup Contact Details

As the source data has the contact name rather than the id, in order to link the contact and supplier we need to lookup and return the Guid ID Dynamics has assigned to each user.

To do this you can either drag and drop the contact entity on to the source contact column, or you can select the source contact column and click onto the add lookup column.

This will open the lookup configuration window where we can specify that the lookup should be configured on the contact fullname. Once the configuration is finished click OK to create the lookup.

Lookup Contact Config

All of the lookup columns can now be accessed from the source window and added to the schema map as needed.

Configure the Schema Map

The next step is to configure the schema map so that the columns we need are included and mapped to their corresponding field in Dynamics. We need to add the Supplier Name, Address details, Phone Number and the Dynamics ID for the contact record which is the ContactID from the contact lookup.

We need to set a key column to uniquely identify each record, for this example this is the externalsupplierid column as this is unique to each supplier.

Schema Mapping

Compare and Synchronise the Results

The final step is to compare the source data to the target data and synchronise the results.

To do this click onto the Compare A > B button in the toolbar and then select the add results to preview what will be added to Dynamics. In this example we can see we have 29 records to add.

Compare Results

To add these to Dynamics click Synchronise and then Start to begin the sync. Once it is complete you will be able to view the newly added records in your Dynamics site.

Preview in Dynamics

For more ideas on how you can use Data Sync to integrate your business apps with Dynamics 365 take a look at our solutions page.