Developing SSRS Reports Using a Query in D365F&O
In this tutorial, we will learn how to develop a report based on a predefined Query in the Application Object Tree (AOT) within Visual Studio. This method is often faster than using a Report Data Provider (RDP) class when complex business logic is not required.
CustTrans table without writing X++ business logic.
Step 1: Create the Project and Query
Unlike previous versions of Dynamics, all development for D365F&O occurs inside Visual Studio.
- Open Visual Studio as an administrator.
- Create a new Finance and Operations project.
- In the Solution Explorer, right-click the project node.
- Select Add > New Item.
- Select Query from the list and name it
CustomerTransactionQuery. Click Add.
Configuring the Data Source:
- Open the Query designer.
- Find the CustTrans table in the Application Explorer (AOT).
- Drag
CustTransinto the Data Sources node of your new query. - Expand the Fields node of the
CustTransdata source you just added. - In the Properties window, locate the Dynamic property and set it to
Yes.
(Note: Setting this to Yes automatically adds all fields from the table to the query, ensuring they are available for the report). - Save the query (Ctrl+S).
Step 2: Create the Report
- Right-click your project in Solution Explorer.
- Select Add > New Item.
- Select Report and name it
CustTransactionReport. - Click Add.
Step 3: Configure the Dataset
Datasets retrieve data from the query defined in Step 1. The dataset acts as the bridge between the D365F&O database and the SSRS report layout.
- Inside the Report Designer (which opens when you double-click your report), look for the Datasets node.
- Right-click Datasets and select New Dataset.
- Name: Enter
CustTransaction. - Data Source Type: In the Properties window, verify this is set to
Query. - Query: Click the ellipsis (
...) button in the Query property field. - In the dialog box that appears, locate and select the
CustomerTransactionQuerywe created in Step 1. - Click Next. Select the fields you wish to display (or check "All").
- Click OK. You should now see the fields listed under your new Dataset.
Step 4: Design the Report Layout
We will use a Precision Design, which allows for custom field placement.
- In the Report Designer, right-click the Designs node.
- Select Add > Precision Design.
- Rename the new design to
Report. - Double-click
Reportto open the SQL Report Designer canvas.
Adding Data to the Layout:
- Open the Toolbox pane (usually on the left) and drag a Table control onto the white design surface.
- Open the Report Data pane (usually on the left). You will see your
CustTransactiondataset there. - Drag fields (like AccountNum, TransDate, AmountMST) from the Dataset directly into the cells of the Table on the design surface.
- Adjust the column widths and header text as desired.
Once designed, Build the solution (Ctrl+Shift+B) to ensure the report is deployed to your local development environment.
Step 5: Create the Menu Item
To run the report from the D365F&O browser client, we need an Output Menu Item.
- Right-click your project, select Add > New Item.
- Select Output Menu Item.
- Name it
CustTransactionReportMI. - In the Properties window for the menu item, set the following:
- Object Type:
SSRSReport - Object:
CustTransactionReport(The name of your report) - Report Design:
Report(The name of your precision design)
- Object Type:
Step 6: Run the Report
- Right-click the
CustTransactionReportMIMenu Item in Solution Explorer. - Select Set as Startup Object.
- Click Start in the top toolbar (or press F5) to launch the D365F&O client.
The browser will open D365F&O. It may take a moment to load. Once loaded, the Report Dialog will appear automatically. Click OK to generate and view the report preview on screen.
No comments:
Post a Comment