Creating an RDL Layout Report
When you create a new report for Dynamics 365 Business Central, there are two things you have to consider; defining the report dataset of data items and columns, and then designing the report layout. These steps will show you how to create a very simple report based on an RDL layout. For more information about the report object, see Report Object. And to learn how to extend an existing report, see Report Extension Object.
Important
RDL layouts can result in slower performance with document reports, regarding actions that are related to the user interface (for example. like sending emails) compared to Word layouts. When developing layouts for document reports, we recommend that you design Word layouts instead of RDL. With Word layouts, reports are not impacted by the security constraints on sandbox app domains like they are with RDL layouts. From a service perspective, RDL layouts are not trusted, so they will run in a sandbox app domain that only lives for the current report invocation.
To create and modify RDL report layouts, you use SQL Server Report Builder or Microsoft RDLC Report Designer. For information about required versions of these tools, see System Requirements.
Create an RDL layout report
To facilitate testing your report layout, the following simple example extends the Customer List page with a trigger that runs the report as soon as the Customer List page is opened.
Create a new extension to the Customer List page that contains code to run the report, as well as a simple report object by adding the following lines of code:
pageextension 50123 MyExtension extends "Customer List" { trigger OnOpenPage(); begin report.Run(Report::MyRdlReport); end; } report 50123 MyRdlReport { DefaultLayout = RDLC; RDLCLayout = 'MyRDLReport.rdl'; }Build the extension (Ctrl+Shift+B) to generate the MyRDLReport.rdl file.
Add the Customer table as the data item and the Name field as a column to the report by adding the following lines of code to the report:
report 50123 MyRdlReport { DefaultLayout = RDLC; RDLCLayout = 'MyRDLReport.rdl'; dataset { dataitem(Customer; Customer) { column(Name; Name) { } } } }Build the extension (Ctrl+Shift+B). The
MyRDLReport.rdlfile will be created in the root of the current project.Open the generated report layout file in Microsoft SQL Server Report Builder.
Edit the layout by inserting a table.
Add the Name column from the Datasets folder into the table and save the .rdl file.
Back in Visual Studio Code, press Ctrl+F5 to compile and run the report in Dynamics 365 Business Central.
You will now see the generated report in preview mode.
Note
If the report layout is not generated, open the settings.json from Visual Studio Code. Use Ctrl+Shift+P, then choose Preferences: Open User Settings, locate the AL Language extension. Under Compilation Options, choose Edit in settings.json and add the following line:
"al.compilationOptions": { "generateReportLayout": true }
Tip
From the Business Central client, you can export report results as raw data to a Microsoft Excel file. The file contains all columns of the dataset, but without the layout applied. Use the file to help validate that the report returns the expected data, and to ensure that the report layout controls match the dataset value types. To export a report, run the report and select the Send to > Microsoft Excel Document (data only) on the request page. For more information, see Working with Reports - Send to Excel.
See Also
Report Design Overview
Report Object
Creating a Word Layout Report
Creating an Excel Layout Report
Defining Multiple Report Layouts
Feedback
Submit and view feedback for