Parag Chapre

How to create a custom entity for Dual-write

In today’s article, I will show how you can create your own custom Dual Write integrations between Dynamics 365 Supply Chain Management and Dataverse. Also, I will show you how to set up the bidirectional mapping.

What is custom entity

The short answer is It is an entity which is not available in the system and can be create manually based on your business requirement.

  • Dual-write provides out-of-box maps for some business processes. However, there might be scenarios where you need additional fields, maps, or transformations.
  • The dual-write platform is extensible.
  • You can create custom maps and extend existing maps with custom fields to sync data between Finance and Operations apps and Microsoft Dataverse.

Before you customize any maps, make sure to check below conditions.

When the entity is in both the F&O and Dataverse

If the entity is in both environments, create a dual-write map.

•Integration keys for the entity should match in both environments. If the entity key isn’t available on either side, be sure to create entity keys. The integration key fields should be mapped to each other in the map.

•The company field should not be present in the mapping if the entity is legal entity–specific, because the company field will already be part of the key. For an example, review the Employments (cdm_employments) entity mapping.

When the entity is in F&O only

If the entity is in the Finance and Operations app only, create a new entity in Dataverse, and then add a map.

•If the Finance and Operations entity contains data that is legal entity–specific, be sure to add a lookup field to cdm_companies in the new Dataverse entity. If the Finance and Operations entity is global, a field for the company isn’t required in the Dataverse entity.

•Add keys to the Dataverse entity to mimic the Finance and Operations entity key. Dual-write requires the same entity keys in both the Finance and Operations environment and the Dataverse environment. The key fields on the Finance and Operations app and Dataverse should be mapped to each other. Don’t add the company field in the mapping.

When the entity is in Dataverse only

If the entity is in Dataverse only, create a new entity in the Finance and Operations environment, and then add a map.

•Create the new entity and include all the required fields. Make sure that the entity is enabled for Data management and public, so that it can be consumed by OData (Open Data Protocol). For more information about how to create a new entity, see Build and consume data entities.

•If data in the Finance and Operations app should be legal entity–specific, be sure to add a lookup field to cdm_companies in the Dataverse entity. If the Finance and Operations entity is global, a field for the company isn’t required in the Dataverse entity.

•Make sure that both entities have the entity key fields. Dual-write requires the same entity keys in both the Finance and Operations environment and the Dataverse environment. The key fields on the Finance and Operations app and Dataverse should be mapped to each other. Don’t add the company field in the mapping. 

Create a custom entity in D365 F&O

You can create an entity by right click on table > Addins > Create data entity

OR

You can use data entity wizard : Create a new data entity

Consider below things when creating custom entity in D365 F&O.

  • Make sure that the entity is enabled for Data management and public, so that it can be consumed by Odata.
  • To enable table maps for dual-write, define an alternative key in the Dataverse table. The value of the alternative key in Dataverse must match the key that is defined in the F&O.

Create a custom entity in Dataverse

  • Enter the table name and add all required fields.
  • Make sure you add key to your Dataverse table which matches with F&O entity.

Map custom entity in Dual-write

Now, we created custom entity in D365 F&O and Power Platform. Lets map this entity in Dual-write for bi-directional sync.

First login to Dynamics 365 F&O and go to Data Management > Click on Dual-write tile

Click on  + Add table map

  • Select table (1) from F&O entity
  • Select table (2) from Dataverse table
  • Create new or select default publisher (3)
  • Enter the version (4) and Description (5)

Sample table mapping in Dual-write

Once you are done then you can see your mapping like this as below.

Test integration

Now, its time to test our integration.

First create new record in Development task overview table in F&O.

Verify data in Dataverse

In the same way, you can change data in Dataverse and you can see update in F&O.

If you like this article, feel free to share it with others who might find it helpful! If you have any questions, feel free to reach out to me.

Leave a Reply

Your email address will not be published. Required fields are marked *