How to: Use an Enum as a Report Parameter
Important
This content is archived and is not being updated. For the latest documentation, see Microsoft Dynamics 365 product documentation. For the latest release plans, see Dynamics 365 and Microsoft Power Platform release plans.
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
This topic provides the steps to use an Enum type as a report parameter. The collection of enumeration values can then be referenced by the report. For example, from the Facility Management sample for Microsoft Dynamics AX, the room type is stored as an enumeration type. You can add a dataset that binds to the RoomType enumeration and restrict the report to display a specific room type, such as Cubicle. You will create the dataset as an AX Enum Provider data source type so that the enum parameter can be accessed from Enterprise Portal in addition to the Microsoft Dynamics AX client.
Creating an Enum Type Parameter
To create a parameter of type Enum, you must have the following:
A data source that contains a field of type Enum. From the Facility Management sample, the data source is the FCMRooms table that contains the RoomType enumeration.
An Microsoft Dynamics AX query based on the data source. From the Facility Management sample, the query is FCMRoomsReport. The data source for this query has a range set for RoomType.
Note
You can set a range on the query or create a filter in Model Editor to provide the filter logic for the enumeration parameter.
The following screenshot illustrates the Facility Management sample FCMRoomsReport query, RoomType range, and FCMRooms data source.
This section describes how to create an enumeration parameter on a report. You will add a dataset bound to a query that contains a range based on an enumeration field. You will add a second dataset that is bound to the enumeration field to convert the parameter to a friendly drop-down list. Then you will reference the second dataset from the report parameter that was generated from the query range. The following screenshot illustrates these elements in the Facility Management model of the FCMRooms report project.
The following numbered list describes the screenshot elements of the FCMRooms report in the Facility Management sample.
The dataset that is bound to the FCMRoomsReport query that has a range set for the RoomType field. RoomType is an Enum type.
The dataset parameter generated from the range that was set for the RoomType field in the query.
The dataset bound to the RoomType enumeration that is used to create a friendly drop-down report parameter on the report.
The name of the enumeration to bind to the AX Enum Provider dataset. Set the Query property to the EnumType property of the enumeration field on the table. To find the EnumType property in the Facility Management sample, the navigation path is Application Explorer > Data Dictionary > Tables > FCMRooms > Fields > RoomType > in the Properties window, Type is set to Enum.
The report parameter generated from the range set on the query to which the dataset is bound. The RoomTypeEnum dataset is referenced from the Values property set on this report parameter.
To create a dataset bound to a query with a range of type Enum
In Model Editor, right-click the Dataset node, and then click Add Dataset.
Select the new dataset and in the Properties window, set the following:
Property
Value
Dynamic Filters
False
Setting the Dynamic Filters property to False and because there is a range set on the query to which the dataset is bound will cause a dataset parameter named RoomType and a report parameter named FCMRooms_RoomType to be generated.
Data Source Type
Query
Query
Click the ellipsis button (...) to open the Select a Microsoft Dynamics AX Query dialog box. You can select a query that is defined in the AOT and identify the fields that you want to use.
Select the FCMRoomsReport query, and then click Next.
Select the All Fields check box.
Expand the FCMRooms_1_FCMPrivateRooms node and then select the All Fields check box.
Expand the FCMRooms_1_FCMPublicRooms node and then select the All Fields check box.
Click OK.
The user needs to select the EnumType field for which the enumeration values will be retrieved. This enumeration will be the same enumeration field that is being used for the query on the dataset. In the following section, FCMRoomType is the enumeration field for which the enumeration values will be retrieved. The FCMRoomType enumeration field was used in the query to restrict which records are retrieved.
To create a dataset bound to an AX Enum Provider
In Model Editor, right-click the Dataset node, and then click Add Dataset.
Select the new dataset and in the Properties window, set the following:
Property
Value
Data Source Type
AX Enum Provider
Query
To find the value, in the Application Explorer, click Data Dictionary > Tables > the table that contains the enumeration field > Fields > the field name that is an Enum type. In the Properties window, the EnumType property is set to the value that you must set in the Query field of the dataset. The drop-down list contains the Microsoft Dynamics AX base and system enums.
The dataset you created now contains three fields that contain metadata for the dataset. In Model Editor, expand the RoomTypeEnum dataset, expand the Fields node, and note the following fields were added: Name, Value, and Label.
To bind the report parameter to the AX Enum Provider dataset
Expand the Parameters node for the report and select the FCMRooms_RoomType report parameter that will be bound to the AX Enum Provider dataset. The naming convention is Dataset_EnumFieldName.
In the Properties window, in the Values property, click the ellipsis button (...) to open the Select Values dialog window. Set the following:
Field
Value
Dataset:
RoomTypeEnum which is the dataset created to retrieve values from the enumeration field.
Value field:
Value
Label field:
Label
You can use the additional properties to control the look of the report parameters, such as whether the parameter is visible or has a default value. Now your report with a report parameter based on an enumeration can be accessed from a Microsoft Dynamics AX menu item or Enterprise Portal.
For the complete steps to use an AX Enum Provider data source type, see Walkthrough: Using AX Enum Provider in a Column Chart Report.