Düzenle

Aracılığıyla paylaş


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 show you how to create a 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.

  1. Create a new extension to the Customer List page that contains code to run the report, and 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';
    
    }
    
  2. Build the extension (Ctrl+Shift+B) to generate the MyRDLReport.rdl file.

  3. 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)
                {
                }
            }
        }   
    }
    
  4. Build the extension (Ctrl+Shift+B). The MyRDLReport.rdl file is created in the root of the current project.

  5. Open the generated report layout file in Microsoft SQL Server Report Builder.

  6. Edit the layout by inserting a table.

  7. Add the Name column from the Datasets folder into the table and save the .rdl file.

  8. Back in Visual Studio Code, select Ctrl+F5 to compile and run the report in Dynamics 365 Business Central.

You'll 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 dataset to Excel, 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.

Report labels in RDL layouts

Report labels are used by report layouts as, for example, the heading for a field in a table, the title for a chart, or the title for the report itself.

Report labels defined in the Labels section of the report object and captions included on dataitem columns using the IncludeCaption property are available as parameters in RDL.

For more information about labels, see Report labels.

Formatting data in RDL layouts

It's often desirable to format data in a report in a different way than how the same data appears in tables, queries, or pages. For example, if a decimal field in a table has precision of five digits, the same level of precision might not be needed in the report.

Specifically for RDL layouts, there are many ways to control formatting of data elements in the RDL language. For more information on how to format data in RDL, see Format paginated report items

Using rich text (HTML) content in RDL layouts

If you've created a Rich Text content control, you can display the text on an RDL report. This means that you can display multi-line formatted text, emphasize important points, and have clickable hyperlinks.

Rich Text is stored as HTML within the database. In order to display the formatted HTML, you need to change the Placeholder Properties within your RDL.

  1. After adding the field to your report layout that contains the Rich Text, left-click on the field so that the <Expr> tag is highlighted.

  2. Right-click on the highlighted <Expr> tag and select Placeholder Properties....

  3. On the General tab, select HTML - Interpret HTML tags as style radio button.

  4. Select OK to close the Placeholder Properties window.

There are limitations imposed by the SQL Reporting Engine as to what HTML markup elements are processed. This Microsoft Learn article states that the following tags will be processed:

  • Hyperlinks
  • Fonts
  • Header, style and block elements
  • Text formatting (bold, italics, underline, strikethrough)
  • List handling

Any other HTML markup tags will be ignored during report processing (for example, images and tables). If the HTML isn't well formed, the placeholder will be rendered as plain text. Unfortunately things like font colors and emojis aren't processed for your report layout.

Note

If the HTML exceeds the size of the page, it will not trigger a page break and continue onto the next page. This means your HTML will be truncated.

Contributors

This article is maintained by Microsoft. Some content was originally written by the following contributors.

See also

Report Design Overview
Report Object
Creating a Word Layout Report
Creating an Excel Layout Report
Defining Multiple Report Layouts