I finally had an opportunity to work on dual write to synchronise data between a CE system and Finance Operations.
MS recommends to use F&O for timesheet entries but our requirement was different, so we had to use CE and then sync it back. To use dual write for this, I had to create a new entity TimesheetLineHdr and the idea was to use the same entity to create and update lines.
The most important bit to start with the process was to know the method call sequence for data entities. The blog helped me with the details
- initValue
- validateField
- validateWrite
- update
- doUpdate
- persistEntity
- doPersistEntity
- initializeDataSources (for each entity)
- initializeEntityDataSource
- mapEntityToDataSources (for each entity)
- saveDataSources
- updateEntityDataSource
- updateEntityDataSource/insertEntityDataSource for insert
- mapDataSourceToEntity
- doSaveDataSource
- updateDataSource
- preupInsertDataSource
- validateWrite of table
!Disable change tracking for initial sync if you want to do inital sync for all records
self refence
If a field is referring to values that dont exist yet but will come in the same sync, remove field and then run the initial sync by disabling change tracking, then add the field again.
Check filters
If the change is not being triggered, check the class BusinessEventsEntityChangeHandler(You can also use this class to track record changes. For "Inserted"/"Updated" events, all scenarios of insert, update,UpdateORInsert_recordset (with without skipDataMEthods) get hit. doinsert,doUpdate does not hit these events).
Check the records on DualWriteProjectConfiguration, DualWriteProjectFieldConfiguration, BusinessEventsDefinition tables to make sure the data against that mapping exists.
If the changes are not being synchronised, the class to lookout for is DualWriteSyncOutbound.
The method WriteEntityRecordToCDS does the main job and you can actually copy the payload from there to copy in your postman and test it manually
D365 CE environment copy issue - Dual write setup can fail if you have restored the dev environment from a production environment. This issue happens because a copy of project parameter gets duplicated as mentioned below
LCS telemetry - debugging issues in tier 2 env
Go to table
1)DualWriteProjectConfigurationEntity - turn on
2)DualWriteErrorLog - check the log for column DetailedErrorMsg - ActivityId
Telemetry https://www.youtube.com/watch?v=gjxcoOhegMc