Tuesday, February 22, 2022

Bring Your Own Database (BYOD) in D365FO

BYOD (Bring Your Own Database) is a feature that helps us export data from D365FO (in full or incremental mode) to external database hosted in the cloud or on-premises. Data transfer is done with the help of data entities and a copy of the staging table is created in the target database. You can use existing entities or create your own entities to structure the data the way you want for your external database.

In this post, I will walk you through the steps involved in setting up and configure BYOD in D365FO.

Step-1: Login in D365FO and  Go to Modules > System Administration > Data Management

           Click  on  > Configure Entity Export to database



Step-2: Click on New button to create a new BYOD data source




Step-3: Enter Source name, Description, Azure SQL / SQL connection string and click on validate.

Connection string should be in the format:
Data Source=xxxxxxxx.database.windows.net,1433; Initial Catalog=xxxxxxxx; Integrated Security=False; User ID=xxxxxxxx; Password=xxxxxxxx;


Once, you click on validate it will show infolog.

Step-4: Click on Publish.


 It will take you to a workspace titled "Target entities", where you can scroll through all entities or search for specific ones.



Step-5: Select the entities you want to export and click "Publish" again. A Job Will schedule and Message will appear once job complete and a table will be created to targeted DB. See Fig 1.1

Note: There is the option to set CHANGE TRACKING for each entity. If you do decide to set this feature, you will be able to export incrementally. If you do not set this, then you can only do a full export. This feature must be set here and for each entity




Fig 1.1: 


Step-6: Now Go back to Systems Administrations > Workspace > Data management 
 and Click on > Export Data 





Step-7: Enter Group name, Description. Click on add entity and fill the required fields like Entity name and select Target data format to your Data source, Default refresh type should be incremental then click on Add.



Note that you also have the option to choose a Default refresh type ("Incremental" or "Full push only")."Incremental" refresh type should only be chosen if we turned on Change Tracking in step 5. Otherwise, select "Full push only".

You are ready to export :) You can also add multiple entities for exporting data.

Step-8: Click on export now. 



You can also export the data in batch for better performance. After completion of data export, you can verify your targeted data source Like below screenshot.



Done!

Sunday, February 6, 2022

SysOperation Framework in D365FO

The SysOperation Framework, initially called Business Operation Framework, seem to be the new substitute of the RunBase framework. As such, it allows you to perform operations that require parameters from the user, it allows you to set the operations to be executed in batch, or in a new asynchronous way, or in a synchronous manner. The great thing is that it simplifies the pack / unpack of variables that was pretty nasty in the RunBase framework, taking advantage of the Attributes feature, introduced with AX 2012.

SysOperation framework allows application logic to be written in a way that supports running operations interactively or via the Microsoft Dynamics AX batch server. It implements the MVC (Model–View–Controller) design pattern, with the isolation of Parameters (Model), Dialog (View) and Service (Controller), for the code that’s executed.

The key objects of the framework are defined below:

  • DataContract
  • UIBuilder
  • Controller
  • Service


DataContract:

The data contract is the model class in which we define which attributes we need for our operation, commonly set as parameters by the user in a dialog. It's nothing more than a model class with a few attributes in it. We can define a SysOperation Data Contract class simply by adding the DataContractAttribute attribute to its declaraion. 

Additionally, if we want a set of methods to be available to us, we can also extend the SysOperationDataContractBase base class. With this class, we can define how our basic dialog will look like to the user. 

We can define labels, groups, sizes and types of the parameters.


UIBuilder:

The UI builder class is actually an optional class for the SysOperation framework, which kind of acts as the view part of the pattern. You should only use it if you want to add some extra behavior to the dialog that AX constructs dynamically for you. If you are perfectly happy with the dialog AX shows you when you run your operation, you shouldn't worry about this class. To create a UI Builder, you should extend the SysOperationAutomaticUIBuilder class. It will provide you a set of methods to work with the dialog's design, but we usually add extra behavior or customize a lookup inside the postBuild method.


Controller:

The controller class has greater responsibility than the others. As the name suggests, it is the class that orchestrates the whole operation. The controller class also holds information about the operation, such as if it should show a progress form, if it should show the dialog, and its execution mode - asynchronous or not. To create a controller class you should extend the SysOperationServiceController, which will give you all of the methods you need.


Service:

There are some who put the business logic on controller classes so that they also perform the operation itself. I'm particularly not a big fan of that, it's too much responsibility for a single class! The programmers who created the SysOperation framework probably think the same, and they have made a way to separate the operation. You can create a service class! The only thing you have to do is extend the SysOperationServiceBase class and you're good to go. This class is the one that should contain all the business logic. When constructing your controller, you will indicate which class holds the operation that the controller will trigger, I'll demonstrate it later.

So this was a brief explanation of SysOperation framework . For more information, you can also download the official Microsoft whitepaper here.

Now, Let's have a look on sysoperation framework with the help of an example:

DataContract Class:

UI Builder:

  


Controller:


Service:


In the last, create a new action menu item that will call the controller class. So in the properties of action menu item  set the 'Object type' to be class and the 'object' to be name of the controller class. In my example, the controller class is named "DemoController".

Here is a screenshot of dialog box from the above UI Builder class defined by single and multiselect parameters.






































It's Done ☺