SysOperation framework in D365 F&O

Rumman Ansari   Software Engineer   2023-11-08   1938 Share
☰ Table of Contents

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.

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 o 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);
    }
}



Data Contract Class:


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

    [DataMemberAttribute('MyField2')]
    public int myField2;
}

In this example, we define a SysOperation framework class called MySysOperationService that extends the SysOperationServiceBase class. This class has a single input parameter called myData, which is defined using a data contract class called MyDataContract.

The processReport method is overridden to execute the logic for the operation, which in this case simply calls a service class called MyServiceClass and passes in the input data.

To use this SysOperation framework class, we would create a new menu item and associate it with this class. We would also create a new form or report to define the user interface for the operation, and customize the logic in the MyServiceClass to perform the desired functionality.

Coding example of MyDataContract class of SysOperation framework in D365 F&O

Here's an example of the MyDataContract class that can be used with the SysOperation framework in D365 F&O:


[DataContractAttribute]
public class MyDataContract
{
    [DataMemberAttribute]
    public str FirstName { get; set; }

    [DataMemberAttribute]
    public str LastName { get; set; }

    [DataMemberAttribute]
    public str Email { get; set; }

    [DataMemberAttribute]
    public int Age { get; set; }
}

In the above example, we have created a MyDataContract class and added four properties to it - FirstName, LastName, Email, and Age. The DataContractAttribute and DataMemberAttribute attributes are used to specify that the class and its properties can be serialized and deserialized.

This class can be used as a parameter for a service operation or as a return type for a service operation in the SysOperation framework.