Today, I will discussing about how to create a batch job using SysOperationFramework in Dynamics 365 Finance And Operations.

Let's suppose we need  get all customer open transaction with negative amount whose payment method is null and update their fields on basis of some logic. Also, user will have option to select number of customers on run time.

In order to achieve our target we need create 3 new class.

1- Contract
2- Service
3- Controller

Step 1- Create a query in my case i have taken join between CustTrans and CustTransOpen tables and added ranges on AccountNum, AmountCur and PaymMode fields.

Step 2- Create a new Contract class and add query in it.

Step 3- Create a new Service class and add method in it for executing the logic and get query from data contract. Execute query by using QueryRun. Add some logic in executeMode method as per your requirement like in my case I need to update some records.

Step 4 - Create a new controller class.

Step - 5 Create a new action menu item and set the controller class name as object and set the
processing method name from service class in parameter field.

Step - 6 Final output of the batch job.