In this blog we are going to cover creating a custom entity in Dynamics, and then how you can synchronise data to this using Data Synchronisation Studio.
Before getting started you need to ensure you have the following:
If you do not have Data Synchronisation Studio you can get a free evaluation edition to try this out.
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.
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.
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.
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.
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.
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.
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).
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:
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).
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.
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.
All of the lookup columns can now be accessed from the source window and added to the schema map as needed.
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.
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.
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.