最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

AX 2012: Customize Controller for Batch Job

网络文摘 William 1884浏览 0评论

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.

Prerequisites:

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:

Untitled

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()
{
    super();

    this.parmClassName(classStr(MAKSalesTableService));
    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
    controller.parmExecutionMode(SysOperationExecutionMode::ReliableAsynchronous);

    // Get the contract from the controller and initialize it default values
    dataContract = controller.getDataContractObject();
    dataContract.parmFromDate(systemDateGet());
    dataContract.parmToDate(systemDateGet());
    dataContract.parmSalesChannel("Direct");

    // call the operation. The controller will handle execution mode
    controller.startOperation();
}

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

Untitled

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 :)

Untitled


发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址