How to: Group and Order Report Parameters by Using a Data Contract Class [AX 2012]
Updated: October 18, 2011
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
This topic describes how to specify the grouping and order of parameters for a report. Report parameters let an end user of a report select or enter the values that are used when the report is printed. A data contract class defines the parameters for a report that is bound to a report data provider (RDP) class. You can specify one or more groups of report parameters, the order of the groups, and the order in which the report parameters appear in a print dialog box. For information about data contracts, see How to: Use a Report Data Provider Class in a Report.
You can also define report parameter groups by using Microsoft Visual Studio. The grouping and order of report parameters that you specify in Visual Studio take precedence over the grouping and order that are defined in the data contract. For more information, see How to: Group and Order Report Parameters by Using Visual Studio.
You use Visual Studio to define the grouping and order of report parameters when the scenario is complex, such as when you want to use multiple nested groups. The benefit of using a data contract class to define the grouping and order of report parameters is that you maintain consistent formatting when you reuse the data contract in another report or in a SysOperation service.
You use two constructs to define the grouping of report parameters:
A data contract class is used to define the groups, the order of the groups, and alignment in the groups.
A data contract method is used to specify the group that a report parameter belongs to, and the order of the report parameter relative to the other report parameters in the group.
Groups are defined in a data contract class. A data contract class is an X++ class to which getters, setters, and the DataContractAttribute attribute are attached. By grouping two or more report parameters, you indicate that the parameters are related to each other. To define a group, attach the SysOperationGroupAttribute attribute to a data contract class.
A data contract class defines the following properties of a group:
The group name
The label that is displayed for the group
The order of the group relative to other groups
The arrangement, either vertical or horizontal of report parameters in the group
To define groups, the order of groups, and the alignment of groups in a data contract class
In the Application Object Tree (AOT), right-click the Classes node, and then click New Class.
Right-click the new class, click Rename, and then enter SrsRDPContractSample.
Expand SrsRDPContractSample, right-click classDeclaration, and then click Code.
Enter the following code in the class declaration to define the class.
A data contract method defines a report parameter. Each report parameter requires a separate data contract method. You can use a data contract method to indicate that a report parameter belongs to a group. You can also specify the order in which the parameter is displayed relative to the other report parameters in the group.
This section describes how to create a data contract method and configure it in the following ways:
Use the DataMemberAttribute attribute to indicate that the method is a data contract method, and to specify the parameter name, AccountNum, that is displayed in Visual Studio when you bind a report data set to an RDP class.
The name that follows the attribute is the parameter name that is displayed in Visual Studio when you bind a report data set to the RDP class.
Use the SysOperationGroupMemberAttribute attribute to indicate that the parameter belongs to the AccountGroup group.
Use the SysOperationDisplayOrderAttribute attribute to indicate that the parameter is displayed first in the group.
To define the order of report parameters in a data contract method
Right-click the SrsRDPContractSample class, point to New, and then click Method.
Edit the method so that it contains the following code.
To use the report parameter groups in the data contract class, define an RDP class. A data contract class defines the report parameters that an RDP class references. For the complete procedure, see How to: Use a Report Data Provider Class in a Report. You then use the Visual Studio Reporting Tools for Microsoft Dynamics AX to define a report that has a dataset that is bound to the RDP class. For information about how to bind an RDP class to a report, see Walkthrough: Creating a Report Bound to a Report Data Provider Class (X++ Business Logic).
The Visual Studio Report Viewer does not display the grouping and order that you specified in the data contract class. To see the report that has the grouping and order of parameters that you specified in the data contract class, you must deploy and run the report from Microsoft Dynamics AX.