SysOperation Framework in D365 F&O - Enhancing Batch Processing and Data Management

Rumman Ansari   Software Engineer   2024-09-24 09:43:36   1232  Share
Subject Syllabus DetailsSubject Details 5 Questions
☰ TContent
☰Fullscreen

Table of Content:

SysOperation framework

Here are the main points about the SysOperation framework in D365 F&O:

  1. The SysOperation framework is a development framework in D365 F&O that provides a standardized way to create and execute long-running operations, such as batch jobs and reports.
  2. It is an enhancement of the RunBase framework and provides additional features and benefits.
  3. The framework allows developers to define the input parameters for an operation, validate them, and present a user interface to the end-user for input.
  4. It then serializes the input parameters and passes them to the server for processing. The server executes the operation and returns the results to the client.
  5. The SysOperation framework provides better separation of concerns between the client and server, improved scalability and performance, and better error handling and logging compared to the RunBase framework.
  6. Developers can use the SysOperation framework to create custom batch jobs and reports, as well as other long-running operations.
  7. The framework provides a flexible and extensible architecture that allows developers to customize and extend it to meet their specific needs.
  8. Overall, the SysOperation framework is a powerful and versatile tool for developers working with D365 F&O, and it can help streamline the development of complex and long-running operations.

When To Use SysOperation Framework in D365

The SysOperation Framework in Dynamics 365 for Finance and Operations is typically used when you need to create batch processing functionality. Here are some scenarios when you may want to consider using the SysOperation Framework:

  1. Large data processing: If you need to process a large amount of data that may take a long time to complete, it’s usually best to use batch processing to avoid affecting the performance of your application. The SysOperation Framework can help you create batch jobs that can process data in the background, without disrupting the user experience.
  2. Report generation: If you need to generate reports that involve complex calculations or large data sets, it’s often best to use batch processing to generate the reports in the background. The SysOperation Framework can help you create batch jobs that can generate reports and save them to a designated location, which can be accessed by users when they need them.
  3. Business logic execution: If you need to execute complex business logic that requires significant processing power or system resources, it’s often best to use batch processing to execute the logic in the background. The SysOperation Framework can help you create batch jobs that can execute business logic and update your system without affecting the user experience.
  4. Integration with external systems: If you need to integrate your Dynamics 365 application with external systems or services, it’s often best to use batch processing to perform the integration tasks in the background. The SysOperation Framework can help you create batch jobs that can send and receive data from external systems, without disrupting the user experience.

Overall, the SysOperation Framework is a powerful tool for creating batch processing functionality in Dynamics 365 for Finance and Operations, and it can help you improve the performance and scalability of your application, while also improving the user experience.


SysOperation framework - Batch Processing Flow in D365 F&O Without UIBuilder

SysOperation Framework - Batch Processing Flow Without UIBuilder
Figure: SysOperation Framework - Batch Processing Flow Without UIBuilder

SysOperation framework - Batch Processing Flow in D365 F&O With UIBuilder

SysOperation Framework - Batch Processing Flow
Figure: SysOperation Framework - Batch Processing Flow


How to develop SysOperation framework in D365 F&O

Developing the SysOperation framework in D365 F&O involves the following steps:

  1. Create a new SysOperation framework class by extending the SysOperationServiceBase class. This class defines the input parameters for the operation, as well as any validation rules and data contract classes that are required.
  2. Create a new menu item for the operation and associate it with the SysOperation framework class.
  3. Define the user interface for the operation by creating a new form or report, as required.
  4. Customize the logic for the operation by overriding the processReport or processBatch methods in the SysOperationServiceBase class.
  5. Implement any required post-processing or cleanup logic in the postRun method of the SysOperationServiceBase class.
  6. Test the operation to ensure that it works correctly and handles errors and exceptions gracefully.

Overall, the process of developing a SysOperation framework class is similar to that of developing a RunBase framework class, but with some additional steps and considerations. The key advantage of using the SysOperation framework is that it provides a standardized way to create and execute long-running operations, with better separation of concerns between the client and server, improved scalability and performance, and better error handling and logging.


Coding Example of SysOperation Framework in D365 F&O

Here's an example code snippet of a basic SysOperation framework class in D365 F&O:

Service Class:

  
  [SysOperationContractProcessingAttribute(classstr(MyServiceClass))]
  class MySysOperationService extends SysOperationServiceBase
  {
      MyDataContract myData;

      [DataMemberAttribute('MyData')]
      public MyDataContract parmMyData(MyDataContract _myData = myData)
      {
          myData = _myData;

          return myData;
      }

      public void processReport()
      {
          MyServiceClass myService = new MyServiceClass();
          myService.doSomething(myData);
      }

      public void doSomething(MyDataContract _myData)
      {
          // Implement your business logic here
          // Example: Display the values of myField1 and myField2
          info(strFmt("Field1: %1, Field2: %2", _myData.parmMyField1(), _myData.parmMyField2()));
      }
  }
  
  

Data Contract Class:

  
  [DataContractAttribute]
  class MyDataContract
  {
      [DataMemberAttribute('MyField1')]
      public str parmMyField1(str _myField1 = myField1)
      {
          myField1 = _myField1;

          return myField1;
      }

      [DataMemberAttribute('MyField2')]
      public int parmMyField2(int _myField2 = myField2)
      {
          myField2 = _myField2;

          return myField2;
      }
  }
  
  

Controller Class:

  
  class MyOperationController extends SysOperationServiceController
  {
      public static MyOperationController construct()
      {
          MyOperationController controller = new MyOperationController(classStr(MySysOperationService),
                                                                      methodStr(MySysOperationService, processReport),
                                                                      SysOperationExecutionMode::ScheduledBatch);
          return controller;
      }

      public static void main(Args _args)
      {
          try
          {
              MyOperationController controller = MyOperationController::construct();
              controller.parmDialogCaption("My Operation Process");
              controller.startOperation();
          }
          catch (Exception::Error)
          {
              // Handle any exceptions that occur during the operation
              error("An error occurred while starting the operation.");
          }
      }
  }
  
  

In this expanded example, we now add a MyServiceClass with a doSomething method that implements some basic business logic, such as displaying the values of the fields in MyDataContract.

By using this setup, we can automate complex processes within Dynamics 365 F&O, and the SysOperation framework helps streamline batch job executions in the background.