Sunday, March 26, 2023

Dual-write application configuration failed

 Hello D365 Community

Point to remember - We can set up Power Platform Integration only during the deployment of the cloud-hosted environment.  So, Power Platform Integration can't be set up after the developer environment is created.

For example, here is a screenshot of the Dev environment in LCS, for which I had set "Configure Power Platform" to No during the env creation. And because of this, the Dual-Write button is missing:



Ref: Enable Power Platform Integration - Finance & Operations | Dynamics 365 | Microsoft Learn

Now, let's move to main subject. I created a new Cloud hosted env with "Configure Power Platform" set to Yes in the deployment wizard.  This went well and as expected I see "Setup Dual-Write application".




Now that env is created, I performed following actions in the env:
  • Link it to DevOps and got latest code from Dev branch.
  • Restore DB backup from our UAT/Sandbox environment.
  • Compile the whole Application.
  • DB sync

Then in LCS, I clicked the button "Setup Dual-Write application" and after few minutes it failed with this message.

Status:  Dual-write application configuration failed. Please click on resume dual write application to try again.
Failure reason: Script [RefreshAXEntities-AOS-Dev-0] failed execution against VM [ABC-Dev03-1]. Last Result: 0xFFFFFFFF ()




I tried "Resume Dual-Write application" with no success.

Fix:  Enable Change Tracking on the SQL Server DB


ALTER DATABASE AxDB
SET CHANGE_TRACKING = ON  
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON)  


Now on clicking "Resume Dual-Write application", it succeeded.

Here is how I found the root cause: 
  • In the FO application, manually ran the "Refresh Entity List" (Location: Data Management workspace -> Framework parameters -> Entity List)
  • The batch job failed with the error "Change Tracking is not enabled on the database: SQL Server Change Tracking"

 Happy coding

Sunday, January 29, 2023

Search for an object in F&O VS Projects Folder

 Sometimes F&O Developers may want to find the Projects in which a particular element was referred.

For example, a MenuItem/Table/Data Entity element that was not checked into the Azure DevOps source control and the original developer is not reachable immediately. 

Then this tip may come in handy...



In this case, I am trying to find the Projects where the custom view "ST5CustDeliveryAddressView" is referred.


My Projects root folder:




Search for the custom view "ST5CustDeliveryAddressView", but no results.



No luck even after selecting the "File contents" in Windows


 

Here is the solution:

Extension for F&O Visual Studio Project file is "rnrproj":




In Windows Explorer, navigate to F&O VS Projects root folder -> Search -> Advanced Options -> Change Indexed Locations

1. Click Modify 

2. add F&O VS Project folder to the existing list of Indexed Locations.





You could open "Indexing Options" tool from the Windows search bar too.


3. Click the Advanced button -> Advanced options dialog -> tab File Types -> 

4. In the text box for "Add new extension to list", key-in rnrproj and click Add


5. Enable "Index Properties and File Contents 

6. Click OK -> Close "Indexing Options" tool

7. Wait for a min, so windows can index the Projects directory

8. Now search for the object/element and you will see the Projects that refer to the element.




Happy Coding.





Tuesday, January 10, 2023

Using Power Platform Data Integrator to integrate F&O Delivery Address Location with CE Account

In this article, we will see how to Integrate D365 F&O Customer Delivery Address Location with D365 CE  Account via Power Platform's Data Integrator. This is going to be a one-way integration from F&O to CE, but you can expand the solution to be bi-directional.

Here is the recording of this Demo:






Low-Code options within the MS ecosystem for the Integration layer:

  1. Dual-Write
  2. Power Platform Data Integrator (approach used in this Demo)
  3. Data Events through Virtual Entity and Power Automate

Limitation in Dual-Write based on my trial:


In F&O Location is Global data and in CE Account is Business Unit specific, this case seems to be not a fit for the Dual-Write framework.  

On trying to save the table map in Dual-Write, this is the error message I received:

Project validation failed. [DIPV1002] ST5CustDeliveryAddressEntity or AX is a cross-company entity that doesn't have primary company field set and accounts of CRM is a company-specific entity with primaryCompanyField set to msdyn_company.cdm_companycode. Please make sure the entities are both cross-company or company-specific entities.

Looks like it is a pre-requisite in Dula-Write, that either both the entities need to be Global or Legal entity specific.

So, I moved on to Power Platform's Data Integrator approach.


Power Platform's Data Integrator approach:

Environments Set-up:

  • I have setup Contoso demo data in F&O 
  • I have setup CE Dataverse to be blank data.
  • Create USMF BU in Dataverse manually (or go through Dual-Write setup which would create this for you).
  • Manually Created a new Customer "San-1" in F&O
        



  • Manually Created a new account "San-1" in CE
            




Security in Dataverse:

In Power Platform, make sure in each Business Unit the default Team has System Admin role. Integration layer uses the default Team of the BU in context.

At the minimum, do this for root BU and USMF BU




F&O Custom Data Entity:

In F&O, I created a custom Data Entity ST5CustDeliveryAddressEntity to expose Customer Delivery Addresses:

Data sources used:

  • LogisticsPostalAddress
  • LogisticsLocation
  • DirPartyLocation
  • CustTable

At the minimum, we would expose the following fields:

  • LocationId (from LogisticsLocation)
  • Description (from LogisticsLocation)
  • AccountNum (from CustTable)
Key: LocationId, ValidFrom

Range: On DirPartyLocation.IsRoleDelivery set to true

Verify the data exposed by OData API, it should render only Customer Delivery Address Locations:

https://<FO instance name>.axcloud.dynamics.com/data/ST5CustDeliveryAddresses

Now Add new Delivery Address with name "Chicago Del-3" on the Customer San-1


Verify that Delivery Address with name "Chicago Del-3" shows up in the OData API output:

https://<FO instance name>.axcloud.dynamics.com/data/ST5CustDeliveryAddresses?$filter=AccountNum%20eq%20%27San-1%27



Data Integrator Project in Power Platform Admin Portal:

In Power Platform Admin Portal -> Data Integration:

  • Create a new Connection Set, to establish a connection between F&O instance and CE instance
    • Here we would select the Organization to be USMF
  • Create a new Project (name could be FO to CE OOB)
    • Associate the Connection set created earlier
    • Select the template to be "Fin and Ops to Sales"
    • Select Organization to be USMF



  • Click the Project created -> Add Task -> 
    • Task Name: FO Delivery Address to CE Account
    • F&O Table: ST5CustDeliveryAddressEntity 
    • CE Table: Accounts
    • Org: USMF
  • Click the Task to add field mappings as per below screenshot

            


  •     Click Filter icon on Source, add following filter:  ((ACCOUNTNO eq "San-1"))
               This way integration fetches only Delivery Addresses related to San-1 customer, to keep the demo simple. You could also use "Advanced query and filtering" feature, which is more like Power Query.

  • Save the Task and Run the Project manually

            



  • Go to Execution History Tab, the run instance would be in status running. 
  • After couple of mins the status would change to Completed
        
        


   



Now go CE All Accounts page, we would see the new Account with name "Chicago Del-3"




Hope this blog comes in handy for the community. 

In the later series, I may try to come up with a similar demo using Data Events (via Virtual Entity) approach.

References:

Data Integrator: Integrate data into Microsoft Dataverse - Power Platform | Microsoft Learn