Walkthrough: Creating Reports in the AOT (MorphX Reporting Tools) [AX 2012]

Updated: March 7, 2011

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

You can create reports that display data that is retrieved by using a query. You can create these reports by using the Application Object Tree (AOT) or by using the Report Wizard.

NoteNote

To access the Report Wizard, click Tools > Wizards > Report Wizard.

In this walkthrough, you will use the AOT to create a report. You will perform the following tasks to create a report by using the AOT:

  • Create and populate tables to use as the data sources for the report

  • Create the report

NoteNote

The example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious.  No association with any real company, organization, product, domain name, email address, logo, person, places, or events is intended or should be inferred.

In this procedure you create a table to use as a data source for the report. For more information, see How to: Create Tables.

To create a table to use as a data source for the report

  1. In the AOT, expand Data Dictionary, right-click Tables, and then click New Table.

  2. Right-click the new table and then click Properties.

  3. On the Properties sheet of the new table, set the Name property to Employee.

  4. In the AOT, expand the Employee node, right-click Fields, point to New, and then click String.

  5. On the Properties sheet of the new field, set the Name property to EmpId.

  6. In the AOT, expand the Employee node in the AOT, right-click Fields, point to New, and then click String.

  7. On the Properties sheet of the new field, set the Name property to FirstName.

  8. In the AOT, expand the Employee node in the AOT, right-click Fields, point to New, and then click String.

  9. On the Properties sheet of the new field, set the Name property to LastName and set the StringSize property to 25.

  10. In the AOT, expand the Employee node, right-click Fields, point to New, and then click String.

  11. On the Properties sheet of the new field, set the Name property to DeptId.

In this procedure you create a second table that will be used as a data source for the report.

To create another table to use as a data source for the report

  1. In the AOT, expand Data Dictionary, right-click Tables, and then click New Table.

  2. Right-click the new table and then click Properties.

  3. On the Properties sheet of the new table, set the Name property to Department.

  4. In the AOT, expand the Department node, right-click Fields, point to New, and then click String.

  5. On the Properties sheet of the new field, set the Name property to DeptId.

  6. In the AOT, expand the Department node, right-click Fields, point to New, and then click String.

  7. On the Properties sheet of the new field, set the Name property to DeptName and set the StringSize property to 25.

  8. In the AOT, expand the Department node, right-click Fields, point to New, and then click String.

  9. On the Properties sheet of the new field, set the Name property to Location and set the StringSize property to 25.

Now you can populate the tables with data that will be displayed in the report.

NoteNote

You can create forms that you can use to add data to tables, but for this walkthrough it is not necessary.

To populate the Employee table

  1. In the AOT, expand Data Dictionary, expand the Tables node, right-click Employee, and then click Open.

  2. Enter the following data into the Employee table and save your changes.

    NoteNote

    Press CTRL+N to add a new row of data or ALT+F9 to delete a row.

    EmpId

    FirstName

    LastName

    DeptId

    0001

    Maria

    Cameron

    Acct

    0002

    Eran

    Havel

    Acct

    0003

    Pal

    Petersen

    Mfg

    0004

    Kim

    Ralls

    Mfg

    0005

    Rebecca

    Laszlo

    IT

    0006

    Nicholas

    Christopoulos

    IT

    0007

    Erik

    Anderson

    Eng

    0008

    Ben

    Smith

    Eng

To populate the Department table

  1. In the AOT, expand Data Dictionary, expand the Tables node, right-click Department, and then click Open.

  2. Enter the following data into the Department table and save your changes.

    NoteNote

    Press CTRL+N to add a new row of data or ALT+F9 to delete a row.

    DeptId

    DeptName

    Location

    Acct

    Accounting

    Fargo, ND

    Mfg

    Manufacturing

    Fargo, ND

    IT

    Information Technology

    Fargo, ND

    Eng

    Engineering

    Washington D.C.

In this procedure you will use the AOT to create a report that displays information from the table you created.

To create the report by using the AOT

  1. In the AOT, right-click Reports, and then click New Report.

  2. Right-click the new report and then click Properties.

  3. On the Properties sheet of the new report, set the Name property to EmployeeReport.

You can specify the data to display and the way to present the data in the report by creating a query in the AOT. For more information, see How to: Create Queries by using the AOT.

NoteNote

You can also create a query by using X++ (see How to: Create Queries by Using X++). Under the EmployeeReport node, right-click Methods, point to Override Method, and then click Fetch. Use the Query system classes to create a query. For more information, see How to: Override the fetch Method to Filter Data for Reports (MorphX Reporting Tools).

First you must specify the data sources to use in the query and the relationship between the two data sources (tables). In this case, the DeptId field is the primary key of the Department table and is a foreign key of the Employee table. For more information, see How to: Add Multiple Data Sources to a Query.

To join the Employee table with the Department table in the report

  1. In the AOT, expand the Reports node, expand the EmployeeReport node, expand the Data Sources node, expand the Query node, right-click the nested Data Sources node, and then click New Data Source.

  2. On the Properties sheet of the new data source, set the Table property to Employee and set the Name property to Employee.

  3. Under the new Employee(Employee) node, right-click the nested Data Sources node, and then click New Data Source.

  4. On the Properties sheet of the new data source, set the Table property to Department and set the Name property to Department.

  5. Under the new Department(Department) node, right-click Relations, and then click New Relation.

  6. On the Properties sheet of the new relation, set the JoinDataSource property to Employee, set the Field property to DeptId, and set the RelatedField property to DeptId.

You can specify what data is returned and how it is displayed in the report by specifying things like a range or a sort order. For more information, see How to: Create Queries by using the AOT. For this report, specify that the query return all employees in Fargo, ND. Create a new range on the Location field of the Department data source.

To define the range of data to display in the report

  1. In the AOT, expand the Reports node, expand the EmployeeReport node, expand the Data Sources node, expand the Query node, expand the nested Data Sources node, expand the Employee(Employee) node, expand the nested Data Sources node, expand the Department(Department) node, right-click Ranges, and then click New Range.

  2. On the Properties sheet of the new range, set the Field property to Location, set the Name property to Location, and set the Value property to ="Fargo, ND".

    NoteNote

    You must include the quotation marks in this case so that the comma is not treated as a delimiter.

To specify the order by which to display the data in the report

  1. In the AOT, expand the Reports node, expand the EmployeeReport node, expand the Data Sources node, expand the Query node, expand the nested Data Sources node, expand the Employee(Employee) node, right-click Order By, and then click New Field.

  2. On the Properties sheet of the new control, set the DataSource property to Employee, set the Field property to LastName, and set the Direction property to Ascending.

To create a report design

  1. In the AOT expand the Reports node, expand the EmployeeReport node, right-click Designs, and then click New Report Design.

  2. On the Properties sheet of the new report design, set the Name property to EmployeeReportDesign.

    NoteNote

    To base the report design on a template, set the ReportTemplate property to one of the predefined report templates.

  3. Right-click the EmployeeReportDesign node and then click Generate Design.

  4. Expand the Generated Design node, expand the Section Group: Employee node, expand the Body:Employee_Body node, expand the Section Group: Department node, right-click Body:Department_Body, point to New control, and then click Field from Employee.

  5. Drag the EmpId, LastName, and FirstName fields onto the Body:Department_Body node.

  6. Right-click Body:Department_Body, point to New control, and then click Field from Department.

  7. Drag the DeptId, DeptName, and Location fields onto the Body:Department_Body node.

  8. Arrange the fields in the order in which you want them to appear in the report.

    NoteNote

    You can also edit the report design by right-clicking the report design and then clicking Edit. You can then move fields around in the Visual Report Designer.

To view the new report

  1. In the AOT, expand the Reports node, right-click EmployeeReport, and then click Open.

  2. Click OK twice and verify the data that you entered into the tables. Erik Anderson and Ben Smith should not appear in the report because their department is not in Fargo, ND.

Community Additions

ADD
Show: