AX 2012: Customize Controller for Batch Job

Posted on Updated on

The purpose of this document is to demonstrate what power we can leverage by customizing the controller for our batch job. For simplicity, we’ll explore how we can set batch dialog fields with default values by extending SysOperationServiceController class.


It is highly recommended to go through the following posts to get a better understanding of what we have done so far in the Batch Framework series.

1. Create a simple batch job.
2. Add fields to batch job dialog.
3. Add lookup to batch job dialog.

Business Requirement:

To set batch dialog fields with default values.

Project Overview:


Development Steps:

1. Create a new class MAKSalesTableServiceController extending SysOperationServiceController base class.

class MAKSalesTableServiceController extends SysOperationServiceController

2. Override the new method and give the following definition:

public void new()

    this.parmMethodName(methodStr(MAKSalesTableService, processRecords));

3. Create a new method main and give the following definition. This is where the magic happens. The controller is used to get reference to data contract object which is then modified to initialize data members, by calling their parm methods, with default values.

static void main(Args _args)
    MAKSalesTableServiceController  controller;
    MAKSalesTableContract           dataContract;

    controller = new MAKSalesTableServiceController();

    // Run operation synchronously, asynchronously or in batch
    // Async execution requires service to be published
    // in the AxClient service group

    // Get the contract from the controller and initialize it default values
    dataContract = controller.getDataContractObject();

    // call the operation. The controller will handle execution mode

4. Modify Menu Items > Action > MAKSalesTableService to point to MAKSalesTableServiceController class just created.


5. Compile and generate incremental CIL.
6. Click Tools > Caches > Refresh elements to refresh the AOD cache to reflect changes on the batch dialog.
7. Click Menu Items > Action > MAKSalesTableService to run the batch job.
8. You should now be getting batch dialog fields initialized with default values 🙂



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s