Thursday, December 26, 2013

Microsoft Dynamics AX 2012 Report Development

There are two types of reports in Microsoft Dynamics AX 2012.

  • Query based report
  • RDP class based report

I will be explaining these reports in details, but before jumping into it we need to be clear about the objects that a developer will be developing for any report.

I am distributing the report development in Microsoft Dynamics AX 2012 into three parts.
In the first part we will discuss what objects are involved in a report development and the purpose of each object in Microsoft Dynamics AX report.

In the second part we will be developing a basic query based report.

In the third part we will be developing a basic RDP based report.

So without further delay, let us start our first chapter of report development which is based on the concepts of report artifacts in Microsoft Dynamics AX 2012.

Following are the common objects required to develop a report in Microsoft Dynamics AX 2012.
  • A contract class
  • An AOT query
  • A Report Data Provider(RDP) class
  • Temporary Table
  • Visual studio AX report project with report design
  • A UIBuilder class(optional/Conditional)
  • A controller class(optional)

Contract Class:-

A contract class in Microsoft Dynamics AX 2012 is responsible for generating an input form. The input parameters are developed through code using “parm” methods. Each parm method will going to end up as an input field on the form which was generated by your contract class.
The contract class has some attributes define on the class level which mark your class as data contract.
You can implement many other interfaces with your contract based on your requirement.

An AOT query:-

This query is responsible for fetching data and to provide your report with a dataset.

Report Data Provider Class:-

Report data provider class is only developed when you need to perform certain actions on the data provided to you by your query. You can manipulate the data from your query into any form in your data provider class.
I will show you an example of RDP class in my upcoming posts, till now all you need to keep in mind that RDP is use to transform data into your desired form and sits between your query and report.

Temporary Table:-

When using a RDP class in your report and you have performed necessary transformation of data, now we are in a stage to store data so that report can fetch it. For this purpose we will be developing a temporary table which will contain the data transformed by RDP class.
The temporary table we use here is only to store the data transformed by RDP class.

Visual studio AX report project with report design:-

For Microsoft Dynamics AX 2012 you need to develop reports in visual studio. All you need to do is to create a report model project add a report in it. Provide the report with your data set.
For query based report, you need reference an AOT query.
For RDP based report, you need to reference your RDP class.
After the dataset you need to work on the design of report. There are two type of designs available in dynamics AX.
  • Auto design
  • Precision design

We will be discussing both of them in detail in future posts.
After the design you need to reference your fields from the dataset(Query/RDP) to the report. Now you need to add your report to AOT and deploy the report.

UIBuilder class:-

The UIBuilder class is use to design your contract form in which you are taking input from user. There are several scenarios in which you need to show or hide different fields on the bases of user selection, also there are scenarios in which you need to show a lookup to user on the report contract.
For the above mentioned scenarios you need to create a UIBuilder clas. In contract class we don’t have enough control on the dynamically created form so we add a UIBuilder class in our report to gain control over the input form of report.

Controller class:-

A controller class has various functions which we can use. There are lot of methods which we can override to achieve our desired functionality. You can modify your query in the controller class. You can apply ranges in your query in the controller class. You can add a logic before the opening of contract of report, similarly you can perform different actions after the contract has been run.

Conclusion:-

The above mentioned objects are the main objects which we need to develop in order to develop a Microsoft Dynamics AX 2012 report.

Thursday, July 4, 2013

Scrollbars appearing on the dynamically created dialog using contract class for SSRS report in AX 2012.

While developing an SSRS report in AX 2012 I was facing an issue. I have dynamically created SSRS report contract using a contract class. On my dialog there was a field parmCompanyAddress to store the address of currently logged in company.

public LogisticsAddressing parmCompanyAddress(LogisticsAddressing _address = companyAddress)
{
    companyAddress = _address;

    return companyAddress;
}

I marked this field as hidden because I don't want my user to view the company address on the contract and binded the value of this field on the report design. But this field created scrollbars on my dynamically created contract form.

To resolve this issue I developed a "UI Builder" class and extend the "Build" method of my "UI Builder" class.

Here is the code that I wrote to overcome this issue,

public void build()
{
    FormBuildTabPageControl tabGeneral;

    super();

    dialogLocal = this.dialog();

    tabGeneral = 
       dialog.dialogForm().buildDesign()                                    .controlNum(1).controlNum(1).controlNum(1); 

    tabGeneral.scrollbars(0);
}

This code fix the issue of scrollbars.

What this code does is,


  • First I called the super method to run the code of base class.
  • Then in the object "dialogLocal" I store the reference of my dynamically created dialog.
  • Object "tabGeneral" is the control which is displaying the scrollbars so I traverse the complete hierarchy to obtain my desired control.
  • When I got my control which is showing the scrollbars, I called its method "scrollbars" and set "0" in it to remove the scrollbars.
Hope the information is useful for you.