Thursday 9 March 2023

D365 FO: ER Diagrams (Entity Relationship Diagrams)

                  D365 FO: ER Diagrams (Entity Relationship Diagrams)

 

 

Today we went to learn about the Visual Studio extension tool which is used to Visualize the D365FO data models.

The tool is called dbdiagram.io, the Database Markup Language (DBML), and the Generate Entity Relation Schema extension for Visual Studio, we can interrogate and transform the metamodel into a visual representation of our entity relationships.

We can download the tool from github.

 

Process of installation:

1.      Download the Waywo.DbSchema.Addin.dll from Releases.

2.      


2.      Unblock the dll. Once the download is done, right-click and view the properties and check Unblock and click ok.



4.      In your Documents\Visual Studio Dynamics 365 folder there is a DynamicsDevConfig.xml XML file. like this:

<?xml version="1.0" encoding="utf-8"?>

<DynamicsDevConfig xmlns:i="http://www.w3.org/2001/XMLSchema-instance"

                   xmlns="http://schemas.microsoft.com/dynamics/2012/03/development/configuration">       

  <AddInPaths xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">            

      <d2p1:string>C:\D365CustomAddins</d2p1:string>       

  </AddInPaths>  

</DynamicsDevConfig>

5.     Edit the XML in note pad and find the tag “AddInPaths

6.     Copy the Waywo.DBSchema.AddIn.dll to the AddInPath folder (create the folder or change the path to where the "Waywo.DbSchema.AddIn.dll" is downloaded.) and then restart Visual Studio.

7.     In the Visual studio from the table designer, right-click àAddinsàGenerate entity relation schema.

8.     


 

Data Entity: PostTargetProcess and PostGetStagingData Methods to Update Target Table D365 FO X++

 Data Entity: Methods to Update Target Table D365 FO X++

 

 

Recently we got a requirement to update the target table with the execution id and show the status of the Entity status on the Dynamics AX Form.

 

In this case, we can use the method “PostTargetProcess” method, which allows you to use DMFDefinitionGroupExecution from where we can get the Entity DefinitionGroup and Execution Id.

This method is automatically called by the Framework class DMFEntityWriter at the end of processRecords() method.

ProcessRecords() method will process all the records transferred from staging to target.

In the below example, we are updating the LedgerJournalTable with ExecutionID, which is used to display the status (error/ completed, etc ) based on execution id.

[ExtensionOf(tableStr(DataEntity))]
final public class DataEntity_Extension
{

  public static void postTargetProcess(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)

    {

        LedgerJournalEntityStaging staging;

        LedgerJournalTable ledgerJournalTableloc;

        select firstonly JournalBatchNumber,ExecutionId from staging

            where staging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup

                && staging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId;

       

        if (staging.JournalBatchNumber)

        {

            ledgerJournalTableloc = LedgerJournalTable::find(staging.JournalBatchNumber);

            if (ledgerJournalTableloc.RecId && ledgerJournalTableloc.MessageId != staging.ExecutionId)

            {

                ttsbegin;

                ledgerJournalTableloc.selectForUpdate(true);

                ledgerJournalTableloc.MessageId = _dmfDefinitionGroupExecution.ExecutionId;

                ledgerJournalTableloc.update();

                ttscommit;

            }

        }

    }

}

 

Like postTargetProcess, we have a method called “PostGetStagingData this method is used to update the data before it gets inserted into the staging table.

public static void postGetStagingData(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)

{

        //logic here

}

Update NuGet package to new MS D365FO version

1. Import the NuGet package files from LCS for that particular version please take the PU version files only. a. Goto LCS-->Asset Libra...