Sunday, June 28, 2015

Build and Deploy Simple Report–Queries

In this post, I will explain about creating a simple AX SSRS Report using the queries from AX AOT. This is what you need to do:
  • Login to AX and open the development workspace
  • Go to AOT –> Queries, right click and select “New Query”
  • Rename the query to “SKL_SampleCustomer”
  • Go to Query’s data source node and right click and select “New Data Source”
  • Rename the data source to “CustTable” and set property table to “CustTable”
  • Now go to the “Fields” node of this query and set property: Dynamic to “Yes”
  • The query looks as shown below
image
  • Save the query
  • Now open visual studio and create a new reporting project by name SKL_SampleReportProject
  • On the reporting model, right click, select “Add” and then Report
  • This will add new report to the project
image
  • Name this report as “SKL_SampleSimpleReportQuery”
  • In the report, Right click on the Dataset node and select “Add Dataset”
image
  • Name the data set as customer
  • On the properties window, ensure following properties are set by default
image
  • In the query property, click the button image
  • This opens up the query selection box to select a Microsoft Dynamics AX Query
  • From the list select “SKL_SampleCustomer” and click Next
image
  • Here you can select required fields. Either you can select all fields or a subset
  • Expand All Fields nodes under the CustTable node to select “AccountNum”
  • Expand Node “All Display Methods” and select “name” and “openBalanceMST”
  • Click “Ok”
image
image
image
  • This will generate the required fields for the dataset
image
  • Now Right click on the designs node, select Add and then “Auto Design”. This creates a new Auto Design and name it as Report
image
  • Select a layout template say “ReportLayoutStyleTemplate”
image
  • Now right click on newly created design select “Add” and “Table”
image
  • Set following properties
    • Name – Cust
    • Dataset – Customer
    • Style Template – TableStyleAlternatingRowsTemplate
  • You will also notice that the fields are included automatically from Dataset to the “Data” node of the table
image
  • Click on Preview once to view the report
image
Note: It may not be possible to preview all reports from VS, especially when there are some internal parameters etc.
  • Now right click on the report model and select option “Add SKL_SampleReportProject to AOT”
image
  • Once the report is added, go to AX, find the report in AOT –> SSRS Reports –> Reports, right click and deploy using “Deploy Element” option
  • Once the deployment is successful, create an output type menu item for the report
  • Go to AOT –> Menu Items –> Output, Right click and select “New Menu Item”. Set following properties
image
  • Now using menu item open and run report.
When you open the menu item, a dialog is automatically made and shown and you will notice that there is also a select button
image




This happens as we had kept the Dynamics Filter property on Dataset in report to “True”. Hence the Reporting framework adds a select button.
The displaying of dialog box can be handled as well. We will cover this topic when we learn about controller classes.
The report will look like this:
image

Note: The name has been intentionally removed from image
Hope this helps you in building your first simple report.

No comments:

Post a Comment