Microsoft Dynamics 365 Dual-Write tips and tricks
Since almost 4 years the Dual-Write framework is being actively used in D365 for near-real-time data synchronization between Dataverse (customer engagement apps, CE) and Finance and Operations apps (FO). The framework is an evolution of CDS (common data service) integration features and provides bidirectional integration incl. the DELETE action. Along with high number of standard mappings available out of the box Dual-Write provides the possibility of customization and development, following the no-code / low-code principle.
In the current article I would like to present some tricks from the practical perspective of work with Dual-Write. First two tricks concern mapping customizations, and the third trick concerns the initial sync scenario between Dataverse and FO.
Trick #1: General Dual-Write pattern is, that the two entities (from CE and FO) set up in a mapping are both
- either company specific
- or cross-company.
The other pattern when the condition is not met (one entity is company specific and another is cross-company) is not supported. When trying to implement this pattern, by saving the mapping one gets the error: Project validation failed. [DIPV1002]
One possible workaround here would be to introduce an intermediate entity for Dual-Write mapping complied with the above pattern and organize data transfer between this intermediate entity and the destination entity.
Trick #2: Let’s consider live sync scenario in the direction FO -> Dataverse. When we have a more complex custom entity with a field related to another FO entity used in another running Dual-Write mapping, a relationship between these two entities must be implemented. The reason for that is, that Dual-Write synchronization (data creation and sending) of related entities occurs in batches. Missing relationships induces multiple batches, which can’t be automatically executed in the correct sequential order, ending up in the run time error: Unable to write data to an entity. Unable to lookup with values {...}. Unable to look up <> with values {...}. Writes to failed with error message Exception message: The remote server returned an error: (400) Bad Request.
An example (custom scenario): creating an employee in FO and synchronizing it via a new custom Dual-Write mapping. When we will add a fully new custom entity containing the field party Id, there must be a relationship linking our custom entity and the standard entity DirPartyCDSEntity from global address book solution. Without this relationship there will be a run-time error (above), indicating, that the new (automatically) created party doesn’t exist. This is obviously not the case (a party is created automatically by creation of a new employee), but Dual-Write live sync of new party id (standard) and the employee (our custom entity) occur in different batches. Just in a scenario when one provides an existing party by creating a new employee, the Dual-Write sync will work in the entity without relationship. Implementing relationships to other entities is a general approach to avoid run time batch synchronization errors.
Standard FO entities, used in standard Dual-Write mappings demonstrate such relationships:
Trick #3 It is well known that Dual-Write synchronization has two modes: live sync and initial sync. When performing initial sync (which is a manual action), one must choose between two options for the master, denoting direction of the desired synchronization: from FO to Dataverse or from Dataverse to FO.
This means, that data will be synchronized from the master to the “opposite side”. It looks logical and is officially documented, but when one checks the Dual-Write logs, one will find out an additional not-documented step. So, the synchronization from master to the “opposite side” is just a first step in the procedure performed by Dual-Write. Following the first step, there will be also a second step, which will be also automatically executed. At this step the data will be synchronized in the opposite direction: from “the opposite side” to the master. This seems not logical in the context of master choice and makes the term “master” confusing. After the whole initial sync is complete (both the two steps executed without errors), the master side will also contain data came from the “opposite side” (which was originally not on master side). One can conclude that Dual-Write initial sync denotes a mixed synchronization, denoting that the master side data will be extended by the data from the “opposite side”.
Interesting fact here is, that even if the first step has failed, the second step will be nevertheless executed. In the case, when there will be no critical issues in the second step, as total result we will get data synchronized in the direction opposite to the original manual choice. This can be very confusing and lead to data loss on master side.
Another consideration is that currently there is no standard possibility to manually force initial sync for a particular data entry of an entity of interest. This would be very practical especially for testing and investigation reasons. The existing initial sync synchronization concerns all (corresponding) data entries from source entity.
Links:
https://ariste.info/en/2021/03/develop-custom-data-entities-dual-write
https://www.linkedin.com/pulse/dual-write-framework-do-dont-adnan-samuel
Published on:
Learn moreRelated posts
Exploring the Differences: Managed vs. Unmanaged Solutions in Dynamics CRM/Dataverse
In Dynamics CRM/Dataverse, solutions are central to Application Lifecycle Management (ALM), providing a structured way to manage, package, and...
Effective Strategies for Debugging Plugins in Dynamics CRM
In a recent interview, I was asked about debugging plugins in Dynamics CRM. The interviewer specifically wanted to know my approach to plugin ...
Is Microsoft Dynamics CRM Affordable for Small Nonprofits?
Satish Reddy By Satish Reddy | Reading time 6 mins When considering a CRM solution, affordability is often a primary concern for small no...
How Microsoft Dynamics CRM Services Helps a Startup Nonprofit
Satish Reddy By Satish Reddy | Reading time 6 mins For startup nonprofits, the right Customer Relationship Management (CRM) system can be...
Easy Plugin Registration Tool Installation for Dynamics 365 CE Developers
Hi Folks, Are you a Power Platform or Dynamics 365 CE Developer, you would definitely need to work on Plugin Registration tool at any given po...
Web resource method does not exist in Dynamics 365 CE
Got the below error while working on Onload of Account record JavaScript in Microsoft Dynamics 365 CE. Script Error One of the scripts for thi...
How to get Environment Variable Value in Dynamics 365 CE using JavaScript?
We might have got a scenario to use the Environment Variable Value in the JavaScript in Dynamics 365 CE. In this article, will explain about r...
Enhancing Business Efficiency with Dynamics 365 CE/CRM AI Capabilities
Artificial intelligence (AI) is a vital catalyst for business transformations in this digital era. A leading player in this revolution
Interview Questions and Answers Dynamics 365 CE and Power Platform – Ultimate Guide
In today's business landscape, Dynamics 365 Customer Engagement (CE) and the Power Platform have emerged as game-changing tools that have tran...
Back to Basics # 72: Limit Special Characters Using a Webresource in Dynamics CRM
Recently we got a requirement to restrict user to enter special characters. Step 1 : Use the below method for restricting special characters S...