5. Add new Report MAKTopProductsSold to the Project node in the Solution Explorer.
6. Add new Precision Design to the Designs node of the report.
7. Right click the precision design and click Edit Using Designer.
8. Drag Chart from the Toolbox.
9. Set Chart axes properties appropriately to show Products on the X-Axis and Quantity on the Y-Axis.

10. Improve formatting of the chart using some professional intellect 🙂
11. Deploy the report to the Report Server using Microsoft Dynamics AX 2012 Management Shell.

12. Create a new controller class MAKTopProductsSoldController and give the following definition for the main method:

Master the Batch Framework in Dynamics AX 2012 by going through the following topics in sequence. The initial topics discuss the basics followed by advanced and complex concepts of the Batch Framework. All the posts will be based on the SysOperation framework which is recommended over the depreciated RunBase framework to develop customized batch jobs.

Following are the topics which are listed in the order of their complexity:

This post builds on the previous topic and describes how to use data contracts to add custom fields to the batch job dialog to control the service operation. It uses the following development artifacts:

This post builds on the previous topic and describes how to develop custom UI builder class extending SysOperationAutomaticUIBuilder base class to add lookups and custom validations to batch job dialog. It uses the following development artifacts:

This post builds on the previous topic and describes how to develop custom controller class extending SysOperationServiceController base class to have more control over execution modes of the service operation as well as initializing dialog fields with default values. It uses the following development artifacts:

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.

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

To have a lookup on the batch job dialog to filter records to be processed based on the user selected value of sales channel field on the dialog.

Project Overview:

We’ll be adding a new UI Builder class MAKSalesTableUIBuilder and link it with the MAKSalesTableContract class to add lookup on the batch dialog. It is highly recommended to read the prerequisites first before proceeding any further to have better understanding of the topic.

3. Compile and generate incremental CIL.
4. Click Tools > Caches > Refresh elements to refresh the AOD cache to reflect changes on the batch dialog.
5. You should be able to see newly added Sales channel field on the batch dialog but without a lookup.

10. Lastly, modify the class declaration of MAKSalesTableContract class to link it with the MAKSalesTableUIBuilder class we just created by decorating it with the SysOperationContractProcessingAttribute:

11. Compile and generate incremental CIL.
12. Click Tools > Caches > Refresh elements to refresh the AOD cache to reflect changes on the batch dialog.
13. Click on the menu item MAKSalesTableService to run the batch job dialog.
14. You should now be getting a lookup generated for the Sales channel field on the batch dialog 🙂

To add custom fields to batch job dialog to choose a date range to process only those records falling in that date range.

Project overview:

As you can see in the picture, a data contract class MAKSalesTableContract has been added to the project to achieve the goal. We’ll be adding from date and to date fields on the batch dialog to capture the date range.

Development steps:

1. Create a new data contract class MAKSalesTableContract with the following class declaration:

This is where the magic happens. Note that method now takes an input parameter of type MAKSalesTableContract class. Then it filters the records to be processed in the while loop by adding ranges to the MAKSalesTable.TransDate field, using the values given by user on the batch dialog for From Date and To Date.

5. Compile and generate incremental IL.
6. Click on Menu Items > Action > MAKSalesTableService to run the batch job.
7. You should now be having 2 fields added to the batch dialog:

In this post we’ll learn how to create a very basic custom Batch job using SysOperation framework. We’ll use the base controller class SysOperationServiceController and develop a custom service operation class to achieve the goal.

Requirement:

To create a Batch job to mark all the records as processed in a custom table MAKSalesTable.

Project overview:

The project shows how simple yet powerful the SysOperation framework is for developing custom batch jobs as opposed to RunBase framework since the minimum development needed to create a fully functional batch job is to create a custom service operation class defining a single method giving the implementation for the batch operation to be performed.

Development steps:

1. Create a service operation class MAKSalesTableService having the following class declaration:

class MAKSalesTableService
{
}

2. Create a new method in the class giving a suitable name like processRecords having the following definition: