Report With Parameters
Report With Parameters
Report With Parameters
In this walkthrough, you will create a report that displays customer data. You will add parameters to the
report to allow users to filter the data that displays in the report.
Defining a query
Creating a reporting project
Creating a report
Adding parameters to a report
Prerequisites
Note
This walkthrough uses the CustTable table. In order to view data in the report, this table
must be populated with data.
Defining a Query
There are several ways to retrieve data for reports. In this walkthrough, you will use a query that is defined
within the Microsoft Dynamics AX development workspace. The following procedure explains how to
define the query that will be used to retrieve data for the report.
To define a query
1
Source: http://msdn.microsoft.com/en-us/library/cc636713.aspx
7. Locate the CustTable table and drag it onto the Data Sources node for the CustomerList query.
8. Expand the CustomerList > Data Sources > CustTable_1 and then click Fields. In the Properties
window, set the Dynamic property to Yes.
9. Save the query.
Next, you will create a reporting project in Microsoft Visual Studio. When you create a Microsoft Dynamics
AX project, you can choose from two project templates: Report Model and EP Web Application. In this
walkthrough, you will use the Report Model template.
Creating a Report
Now that you have created a reporting project, you are ready to create the report. The following
procedure explains how to create the report.
To create a report
1. In Solution Editor, right-click the SampleCustomerListReport project, point to Add, and then
clickReport.
2. In Model Editor, click the report and type CustomerList as the name.
3. Right-click the Datasets node, and then click Add Dataset.
4. Select the node for the dataset.
5. In the Properties window, specify the following values.
Property Value
Data Dynamics AX
Source
Data Query
Source
Type
Default Table
Layout
Dynamic False
Filters
Name Customers
Query Click the ellipsis button (…). A dialog box displays where you can select a
query that is defined in the AOT and identify the fields that you want to use.
Select the CustomerListQuery and then click Next. In the Select
Fields window, expand the All Fields node and then select
the AccountNum field. Expand the All Display Methods and select
the Address,Name, Phone and TeleFax fields. Click OK.
6. In Model Editor, select the Customers node and drag it onto the Designs node. An auto design
namedAutoDesign1 is created for the report.
7. Select the AutoDesign1 node.
8. In the Properties window, set the LayoutTemplate property to ReportLayoutStyleTemplate.
Also, typeCustomer list for the Title property.
9. In Model Editor, expand the AutoDesign1 node, and then select the node for the table data
region.
10. In the Properties window, set the Style Template property to TableStyleTemplate.
Next, you will add parameters to the report. First, you will add a parameter and a filter that uses the
parameter to allow users to select a customer for which to display data. Then, you will add parameters
that will be used to determine whether to display the phone and fax numbers for the customers in the
report. The following procedures explain how to define the parameters for the report.
1. In Model Editor, right-click the Parameters node for the report, and then click Add Parameter.
2. Select the node for the parameter.
3. In the Properties window, specify the following values.
Property Value
Multi False
Value
Name CustomerName
Prompt Customers:
String
Values Click the ellipsis button (...). In the dialog box that displays, click the From
Dataset radio button. Select Customers from the drop-down menu for Dataset.
Select name from the drop-down menu for Value Field, and select name from
the drop-down menu for Label Field. Click OK.
4. Expand the AutoDesign1 node, and then expand the node for the table data region.
5. Right-click the Filters node, and then click Add Filter.
6. Select the node for the filter.
7. In the Properties window, specify the following values.
Property Value
Expression =Fields!name.Value
Name SelectCustomers
Operator In
Value =Parameters!CustomerName.Value
8. To preview the report, right-click the AutoDesign1 node in Model Editor, and then click Preview.
The parameter that you defined displays in the Parameters window.
9. To use the parameter, select a customer name from the list that displays for the parameter, and
then click the Report tab. The data for the selected customers displays.
10. Close the Preview window
To add parameters that determine whether to display phone and fax numbers
1. In Model Editor, right-click the Parameters node, and then click Add Parameter.
2. Select the node for the parameter.
3. In the Properties window, specify the following values.
Property Value
Data Boolean
Type
Name DisplayPhoneNumber
4. In Model Editor, right-click the Parameters node, and then click Add Parameter.
5. Select the node for the parameter.
6. In the Properties window, specify the following values.
Property Value
Data Boolean
Type
Name DisplayTeleFaxNumber
Values Click the ellipsis button (...). In the dialog box that displays, click the Non-
queried radio button. In the first row in the table, type True in
the Value column and type Yes in the Labelcolumn. In the second row,
type False in the Value column and type No in the Labelcolumn. Click OK.
7. In Model Editor, expand the AutoDesign1 node, expand the node for the table data region, and
then expand the Data node.
8. Select the Phone field, and type the
expression =IIf(Parameters!DisplayPhoneNumber.Value=True, True, False) for the Visible property
in the Properties window.
9. Select the TeleFax field, and type the
expression =IIf(Parameters!DisplayTeleFaxNumber.Value=True, True, False) for
the Visible property in the Properties window.
10. To preview the report, right-click the AutoDesign1 node in Model Editor, and then click Preview.
The new parameters display in the Parameters window along with the previous parameter. To
use the parameters, select one or more customers and specify Yes or No for the two display
parameters. The data for the selected customers displays.
11. Close the Preview window