Microsoft_MVP_banner

Another step closer – Finance Operations data in Power Platform – Virtual Entities

Another step closer - Finance Operations data in Power Platform - Virtual Entities

This post focuses on the integration technologies available to have the Microsoft Dynamics 365 Finance Operations data available in Dataverse/Common Data Services/CDS. What could be better then having The biggest ERP system’s data in Power Platform. You can Power Portals, Power Apps, Power BI analytical reports, use power virtual agents for inventory closing and year end closing processes, manage expenses and employee/contractors time entry processes, most of these processes can be even without logging to MS ERP (Dynamics 365 Finance Operation) so can safe on license cost too.  Let’s see what options are available to integrate F&O data with Power Platform however, this post is dedicated to Virtual Entities.  3 Options available out-the-box to integrate F&O data with Power Platform; 👉 Data Integrator – Click on link to read more 👉 Dual-Write – Click on link to read more 👉 Virtual Entities – MS Tech Talk on Virtual entities  Before we jump to the installation and configuration part, let’s see when were the virtual entities available and what features these have come up with compared to other two integrations technologies. Virtual Entities Generally available ✔️ Finance and Supply Chain Management App: 10.0.12 or later ✔️ Dataverse: Service update 189 or later Virtual Entities features ✔️ Finance and Operations is available as a data source in Dataverse ✔️ No Finance and Operations data replication in Dataverse ✔️ Access all public data entities of Finance and Operations in Dataverse ✔️ Support all CRUD operations Install Virtual Entities solution Head to this link https://appsource.microsoft.com/en-us/product/dynamics-365/mscrm.finance_and_operations_virtual_entity and Get it Now Enter your work or school account and Sign in Choose the environment where you want to install this solution Wait for finish to installing Finance and Operations Virtual Entity solution shows as Enabled Finance and Operations Virtual Entity solution is installed successfully – Hurray!! that was easy Register an App in Azure Active Directory The AAD application must be created on the same tenant as F&O. Log on to http://portal.azure.com Azure Active Directory > App registration New Registration Define these attributes Name Account type Redirect URI – leave blank Select Register Make note of the Application (Client) ID, you will need it later Create a symmetric key for the application, Save and note it for later use. Steps to follow in Dataverse environment  Log on to Dataverse environment and click on Advance settings Go to Administrator Choose Virtual entity data sources Finance and operations is available as of the data source in Dataverse Click on Finance and Operations and following screen pops up, this is where the connections established Configuration in Finance and Operations Log on to Finance and Operations and go to System Administration | Users | Users Create a new user and assign ‘CDS virtual entity application’ role to it – don’t assign system admin role to this user – This user is used to look at the metadata of the data entities from the Dataverse instance. Enter Application Id in System Administration | Setup | Azure Active Directory applications screen with the User ID = <The user created in step 1> Test Finance and Operations data in Dataverse Log on to Dataverse instance and click on a little funnel to open advance find and look for ‘Available Finance and Operations Entities’ in the list of tables in Dataverse instance.  By default not all the entities are enabled this is to avoid cluttering the user experience in Dataverse but individual entities can be enabled e.g. I enabled DataManagementDefinitionGroupEntity and mark visible to make this as a virtual entity in Dataverse. To illustrate this example, I created an export data project in Finance and Operations under Data Management with the name ‘CDSVirtualEntitiesExport’ – The data entity behind this data export projects is DataManagementDefinitionGroupEntity which is marked as virtual entity in above step.  Restart the Advance find in Dataverse instance and look for Definition Group (mserp) table map and Run to see the output This is it for today, with next post I will explain how to do customization/extension in F&O and get data into Dataverse using Virtual Entities.  Hope you may have enjoyed the post, please do provide your feedback. Enjoy your break!!

D365FO: Entity cannot be deleted while dependent Entities for a processing group exist. Delete dependent Entities for a processing group and try again.

D365FO: Entity cannot be deleted while dependent Entities for a processing group exist. Delete dependent Entities for a processing group and try again.

Scenario: There are times when you want to delete an entity from target entity list and when you do so, you face an error message which does not tell you where exactly the entity has been used.  “Entity cannot be deleted while dependent Entities for the processing group exist. Delete dependent Entities for a processing group and try again.“ Solution: Browse the environment by appending this part /?mi=SysTableBrowser&TableName=DMFDefinitionGroupEntity&cmp=USMF at the end.  For example; if the environment URL is https://daxture.sandbox.operations.dynamics.com then the complete URL will be https://daxture.sandbox.operations.dynamics.com/?mi=SysTableBrowser&TableName=DMFDefinitionGroupEntity&cmp=USMF Filter for Entity and it will give you the DefinitionGroup where the entity has been added or used in data management import/export projects. Get the DefinitionGroup name and search in the export/import projects under data management and either delete the whole project or remove the entity from the group. Try deleting/removing entity from target entity list and it should be good now.

How to run dual-write table map when underline entity table is setup under cross-company data sharing policy

How to run dual-write table map when underline entity table is setup under cross-company data sharing policy

Scenario:  Project groups are shared across all legal entities in D365 finance & operations app so have setup under one of the cross-company data sharing policies. You are also required to setup dual-write table map for project groups to sync from FO to CDS. However, you get following error message when you try to Run the table map “Copying pre-existing data completed with errors. For additional details, go to initial sync details tab.” Follow these steps to overcome this issue as a workaround.  Steps to follow: Disable cross-company data sharing policy where ProjGroup table has been used Choose Yes at next pop up window Go to Data management > Dual write > select Project Groups table map and Run Enable cross-company data sharing policy for project groups Choose No at the next pop up window unless you want to copy data across all companies

Steps to follow when refresh dual-write integrated environments (FO and CE)

Steps to follow when refresh dual-write integrated environments (FO and CE)

Scenario:  The D365 finance & operations app is linked to Common Data Services through dual-write in development or sandbox environments. You are required to refresh databases in D365 FO and CDS both from another production environment (dual-write integrated (linked) environments in the scenario) Steps to follow: Before initial refresh, log on to target environment Go to Data management > Dual write and stop all jobs Refresh FO and CDS environments from the same integrated source environments Go to Data management > Dual write and Unlink environments Clean data from following tables in D365FO if data exists DualWriteProjectConfiguration – A sample URL would be like this to access tables from D365FO environment <Environemnt URL>/?mi=SysTableBrowser&prt=initial&limitednav=true&TableName=DualWriteProjectConfiguration&cmp=<CompanyId> DualWriteProjectFieldConfiguration- A sample URL would be like this to access tables from D365FO environment <Environemnt URL>/?mi=SysTableBrowser&prt=initial&limitednav=true&TableName=DualWriteProjectFieldConfiguration&cmp=<CompanyId> Clean data from DualWriteRunTimeConfiguration Table in Dataverse [Customer Engagement] – Click on little funnel on top right side of the CE environment to open table browser or Advance find and look for Dual write Runtime configuration table Link Environments Apply MS dual-write solutions and your custom solution if there is any Start jobs and no need for initial sync, both environments are already sync as were copied from another dual-write integrated source environments

Dual-write integration for Cross-Company data in D365 Finance and SCM

Dual-write integration for Cross-Company data in D365 Finance and SCM

Dual-write does not work with the cross company data sharing policies in D365 FinOps (there are so many names but I am using this name for reference 😊). Brief overview about cross company data sharing policy first to set the base for the readers, the Cross-Company data sharing lets you have your data accessible from multiple legal entities (companies in D365 FinOps). For example, if you setup a policy for vendors to be crossed-company then whenever you create a new vendor it will be created in all data sharing legal entities. https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/sysadmin/cross-company-data-sharing Now, What happened when you a table under cross-company data sharing (e.g. VendTable) and want to sync vendors through dual-write? Since, VendTable is one of the data sources for Vendors data entity (dual-write entity map) and we know dual-write does not work well with cross-company data sharing by design. You get following error message when you try to Run the entity map. “Copying pre-existing data completed with errors. For additional details, go to initial sync details tab.” The error message is confusing and does not reflect the actual issue behind the scene – you will never be able to figured it out what is wrong until you raise it with MS dual-write team and share the activity Id of the job with them to investigate the telemetry (you don’t have access to check this one 😒) then they share the root cause. However, You can also investigate by putting a breakpoint in method validateDataSharingEnabledForEntityTableBeforDualWriteEnable() of class SysDataSharingValidation.   /// <summary>     /// Validates that cross company data sharing is not enabled when enabling Dual Write.     /// </summary>     /// <param name = “_entityName”>The name of the entity containing the table being enabled</param>     /// <param name = “_tableName”>Table in entity</param>     /// <param name = “_dataAreaId”>Company info</param>     [SubscribesTo(classStr(BusinessEventsRegistrationBase), staticdelegatestr(BusinessEventsRegistrationBase, onTableEnabled))]     public static void validateDataSharingEnabledForEntityTableBeforDualWriteEnable(str _entityName, str _tableName, DataAreaId _dataAreaId)     {         SysDataSharingOrganization sysDataSharingOrganizationTable;         SysDataSharingRuleEnabled sysDataSharingRuleEnabledTable;           select firstonly SharedTableName from sysDataSharingRuleEnabledTable                 where sysDataSharingRuleEnabledTable.SharedTableName == _tableName                     join DataSharingPolicy, DataSharingCompany from sysDataSharingOrganizationTable                          where sysDataSharingRuleEnabledTable.DataSharingPolicy == sysDataSharingOrganizationTable.DataSharingPolicy                 && sysDataSharingOrganizationTable.DataSharingCompany == _dataAreaId;           if (sysDataSharingRuleEnabledTable)         {             throw error(strFmt(“@DataSharing:CrossCompanySharingError“, _entityName, sysDataSharingOrganizationTable.DataSharingPolicy));         }     }  

D365FO: LCS Exported Bacpac File Contains Corrupted Data

D365FO: 𝙇𝘾𝙎 𝙚𝙭𝙥𝙤𝙧𝙩𝙚𝙙 𝙗𝙖𝙘𝙥𝙖𝙘 𝙁𝙞𝙡𝙚 𝙘𝙤𝙣𝙩𝙖𝙞𝙣𝙨 𝙘𝙤𝙧𝙧𝙪𝙥𝙩𝙚𝙙 𝙙𝙖𝙩𝙖

If you experience the below error message when trying to import bacpac file into tier 1 (DEV) environment then use the suggested steps to get over this error and get your database imported. Importing to database ‘AxDB_Daxture’ on server ‘.’. SqlPackage.exe : *** Error importing database:Could not load package from ‘C:UsersAdminb1c06345afDownloadsdaxturebackup.bacpac’. At line:13 char:5 +     & $LatestSqlPackage $commandParameters “/p:CommandTimeout=0” +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : NotSpecified: (*** Error impor…backup.bacpac’.:String) [], RemoteException     + FullyQualifiedErrorId : NativeCommandError     File contains corrupted data.   Based on this docs link https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/database/import-database, download the .NET CORE version of SqlPackage.exe.   This is the .zip file that can be extracted to C:TempSqlpackage-dotnetcore From there, instead of using the Sqlpackage.exe under C:Program Files (x86), use the Sqlpackage.exe in C:TempSqlpackage-dotnetcore. Command will be: C:TempSqlpackage-dotnetcore>SqlPacage.exe /a:import /sf:D:Exportedbacpacmy.bacpac /tsn:localhost /tdn:<target database name> /p:CommandTimeout=1200    

Tips and Tricks on how to validate your dual-write integration field-by-field level – its easy believe me 😊

Dual-write learning series - Dual-write initial sync is the data integrator

After you are done with your entity field mappings for a required entity map e.g. for Vendor Groups, we started to look at in previous post to get the payload for dual-write integration, two records get created in the following tables. 1. DualWriteProjectConfiguration 2. DualWriteProjectFieldConfiguration Records only get created when you Run the entity map and get deleted once you stopped it. DualWriteProjectConfiguration table does not hold data for Vendor groups when the entity map is stopped. DualWriteProjectFieldConfiguration table does not hold data for Vendor groups when the entity map is stopped. Run the entity map and check data in these tables,   1. Both tables link each other using Name field 2. For each entity map (e.g. Vendor groups) there are two records; one for Insert and Update and the other one is for delete which ends with _end Import information about DualWriteProjectConfiguration table: 1. External URL field holds the CDS environment’s URL which is linked with FO in this format https://<CDS environment URL>/api/data/v9.0/msdyn_vendorgroups. This API URL can be browsed to see available data in CDS environment 2. Project partition map field holds list of legal entities linked for dual-write, you can copy this list in notepad++ (or any where) and check all legal entities from there too – this may help you in troubleshooting 3. IsDebugMod field if marked then failure records are stored in DualWriteErrorLog table 4. Filter query expression field if you have defined Finance and Operations apps filter for entity maps it stores here Import information about DualWriteProjectFieldConfiguration table: Filter records from this table based on the project name you have retrieved from DualWriteProjectConfiguration table as shown below as an example 1. External lookup urls field holds information how different lookups from CDS tables are linked for this integration. Trick and Tip: Copy data from this field and paste into Notepad ++, data looks like this Format JSON and you can review all data easily in JSON viewer 2. Field mapping field holds information on how fields are mapped between both apps (Finance Operations app and Common Data Service) Trick and Tip: Copy data from this field and paste into Notepad ++, Format JSON and it shows like this DualWriteProjectConfigurationEntity data entity is the triggering point to sync data across based on pre-defined sync direction as discussed above. In case you want to debug outbound call for vendor groups this will be the stack trace. I hope this may have helped you to understand the tables and classed behind dual-write and troubleshoot your issue at some point. If you still have any question please reach out to me via comments section.

Want to see the inbound and outbound Payload for dual-write integration

Want to see the inbound and outbound Payload for dual-write integration

Let’s continue where we left in first post “What got changed (Technical) in D365 Finance Operations with dual-write” our journey to understand what are the technical changes being done for dual-write framework. This post we will look at what are highly used tables, entities, and classes involved for dual-write sync. I will only cover few tables, classes, and data entities but complete list of objects can be explored from AOT as shown below. Business scenario: Create or update Vendor Groups in FO and sync over to CDS and vice versa. Open Vendor groups screen – Accounts Payable > Vendors > Vendor groups Out-of-the-box dual-write template is available for vendor groups These fields are mapped between Finance and Operations apps and Common Data Service for Vendor groups dual-write template. NOTE: only data will sync between apps only for mapped fields and the integration will also only trigger when we change data for these mapped fields in either side of the integration apps (FO or CDS) provided the sync direction is set to bi-directional (which is set for this scenario). Requirement: You want to debug the integration (outbound or inbound) Two important classes: 1. DualWriteSyncInbound 2. DualWriteSyncOutbound If you want to debug data going out of FO to CDS (Outbound) then put a breakpoint at method WriteEntityRecordToCDS() of class DualWriteSyncOutbound. This is quite extensive method and also gets a payload going out of FO to CDS, this payload can be watched and changed using all debugging features of D365 Finance and Operations. Method BuildCDSPayload() being called inside method WriteEntityRecordToCDS() creates complete payload. Pasting this just for reference purpose, this is subject to change at anytime so always refer to the updated code. internal str BuildCDSPayload(str cdsLookupUrls, common entityRecord, str fieldMappingJson, ICDSSyncProvider syncProvider)     {         var executionMarkerUniqueIdentifier = newGuid();         DualWriteSyncLogger::LogExecutionMarker(‘DualWriteOutbound.BuildCDSPayload’, true, strFmt(‘Execution start for record %1 with uniqueId %2’, entityRecord.RecId, executionMarkerUniqueIdentifier));         CDSPayloadGenerator payloadGenerator = syncProvider.CDSPayloadGenerator;            responseContract.DualWriteProcessingStage = DualWriteProcessingStage::TransformingSourceData;                    FieldMappingIterator fieldMappingIterator = FieldMappingIterator::ReadJson(fieldMappingJson);         if (fieldMappingIterator == null)         {             responseContract.AddRecordResponse(ExecutionStatus::Failed, strFmt(“@DualWriteLabels:InvalidFieldMapping”,fieldMappingJson), ”);             DualWriteSyncLogger::LogSyncError(‘BuildCDSPayload’, ”, ”, strFmt(‘Failed to create CDS payload. Error reason %1′, responseContract.GetFormattedResponseObject()), DualWriteDirection::Outbound);         }         while (fieldMappingIterator.MoveNext())         {             FieldMapping fieldMapping = fieldMappingIterator.Current();             var valueTranforms =  fieldMapping.ValueTransforms;             var sourceValue = this.FetchSourceFieldDataFromMapping(entityRecord,fieldMapping);             // If there is a value default value transform then the payload creation is skipped             // The payload gets added in CDSSyncProvider             boolean skipPayloadCreation = false;             if (valueTranforms != null)             {                 var transformEnum =  valueTranforms.GetEnumerator();                 while (transformEnum.MoveNext())                 {                     IValueTransformDetails transform = transformEnum.Current;                     sourceValue = this.ApplyValueTransform(transform, sourceValue);                                         skipPayloadCreation = (syncProvider.GetProviderType() != CDSSyncProviderType::CDSQueueSync &&                         transform.TransformType == ValueTransformType::Default);                     if (transform.HasTransformationFailed)                     {                         responseContract.AddFailedFieldResponse(fieldMapping.SourceField, strFmt(“@DualWriteLabels:FailedTransform”, sourceValue, fieldMapping.SourceField, enum2Str(transform.TransformType)), ”);                     }                 }             }             if (!strContains(fieldMapping.DestinationField,’.’) || fieldMapping.IsSystemGenerated)             {                 if (!skipPayloadCreation)                 {                     payloadGenerator.AddAttributeValuePair(fieldMapping.DestinationField,                             sourceValue,                             fieldMapping.IsDestinationFieldQuoted,                             this.FetchSourceFieldTypeCode(entityRecord, fieldMapping));                 }             }             syncProvider.AddSourceColumnTransformedValue(syncProvider.GetMappingKey(fieldMapping.SourceField ,fieldMapping.DestinationField) ,sourceValue);         }                 responseContract.DualWriteProcessingStage = DualWriteProcessingStage::ResolvingLookups;         var cdsPayLoad = syncProvider.BuildCDSPayloadForLookups(cdsLookupUrls, fieldMappingJson);         DualWriteSyncLogger::LogExecutionMarker(‘DualWriteOutbound.BuildCDSPayload’, false, strFmt(‘Execution ends for record %1 with uniqueId %2’, entityRecord.RecId, executionMarkerUniqueIdentifier));         return cdsPayLoad;     } To debug data coming in FO from CDS (Inbound) then put a breakpoint at method WriteDataToEntity() of class DualWriteSyncInbound. Pasting this just for reference purpose, this is subject to change at anytime so always refer to the updated code. private ResponseContract WriteDataToEntity(str entityName, str entityFieldValuesJson, str companyContext, boolean runValidations = false, boolean isDelete = false, DualWriteTransactionId transactionId = ”, str CDSSyncVersion = ”, boolean isBatchCommit = true)     {         var executionMarkerUniqueIdentifier = newGuid();                      this.InitializeInboundSync(entityName);                 return reponseContract;     }

What gets changed (Technical) in D365 Finance Operation with dual-write

What gets changed (Technical) in D365 Finance Operation with dual-write

Being a developer I have to explore how a new feature or a framework has been developed and how can this be extended when needed. While working on dual-write implementation I came across many technical difficulties as the framework was not mature enough at that time since the dual-write is only generally available in end of March 2020 and I have been working on dual-write since mid-year 2019. I must say MS has done tremendous amount of work to make the integration with Microsoft Dynamics 365 Finance Operations apps and Common Data Services via Dual-write Bunch of AOT objects have been added at D365 FO side – screen shot taken from 10.0.13 these can grow with future releases if needed. Application class has also been modified for dual-write, below method gets called when the database transaction tries to get committed, between ttsbegin and ttscommit. public void ttsNotifyPreCommit()     {         if (!isInTtsNotifyPreCommit)         {             try             {                 isInTtsNotifyPreCommit = true;                 if (sysTransactionScope)                 {                     sysTransactionScope.onTtsCommitting();                 }                                     super();                                     if(this.canRaiseEvent())                 {                     this.onTtsNotifyPreCommit();                 }                   // Checks that all suspension of recId allocation invoked by calling appl.SysRecIdSequence().suspendRecIds() have been removed.                 if (sysRecIdSequence)                 {                     if (!this.sysRecIdSequence().areAllRecIdSuspensionsRemoved())                     {                         throw error(“@SYS344764”);                     }                     sysRecidSequence = null;                }                  if (this.ttsLevel() == 1)                {                    DualWriteChangeProcessorBase::processTransactionPrecommit();                }             }             finally             {                 isInTtsNotifyPreCommit = false;             }         }     } Dual-write triggers only at ttsLevel 1, to understand this concept I did a small test. From the trace log I can see that before ttscommit it goes to Application::ttsNotifyPreCommit and from there is makes a call to DualWriteChangeProcessorBase and in my scenario it goes to DualWriteSyncOutbound class. If you dig deeper in this class, this creates the complete JSON message and sync this to CE. In my next post, I will show what tables, entities, classes are involved and how you can see what JSON message is going out from FO to CE. Stay tune.

FaisalFareed@2025. All rights reserved

Design by T3chDesigns