BC AL Journey #30

In our exploration of reporting technologies in Business Central we have covered Excel and Word (Part 1 and Part 2) reports. The final reporting technology we are going to explore is the RDLC report.

RDLC stands for Report Definition Language Client, which is an extension on the original RLD, Report Definition Language, which dates back to the SQL Server Reporting Services systems. The main difference between the RDL and RLDC systems is that the RDLC is capable of self-hosting the report and can contain the data, where the RDL simply defines the report and must be hosted.

Unlike the Word and Excel reports, this is going to require software not typically included in your common desktop. We will need to install the Microsoft Report Builder.

After downloading the software and starting the installation, we may recognize a logo.

That is the logo of the Power BI Team. RDLC Reports are also used for paginated reports in Fabric and the technology supporting that is now part of the Power BI family of products. There are no options in the install except for installation location, so I’m going to assume you can click “next” and “finish” without additional screenshots.

Let’s start by editing an existing report, the Customer List report (number 101) is a nice simple report. In Business Central, go to “Report Layouts”, find “Customer List” and Export the Layout.

This will trigger a download of “CustomerList.rdlc”. Open that with Microsoft Report Designer. Here is where we hit our first challenge, Microsoft Report Builder only recognizes RDL files. You will either have to rename the file to end in .RDL or put the entire file path into the name field of the open dialog box.

Once opened, you should see something like this:

On a new installation, it is helpful to display the Properties dialog. Click on the View tab and select the Properties checkbox.

Let’s compare the report output from Business Central with the Report Design in Microsoft Report Builder.

We can see that the green, orange, and yellow boxes are text boxes, the blue box contains a table of data. The really powerful thing about these reports is unlike a Word report, which is a document and therefore the layout is flow based, elements in an RDLC report are placed based on exact positions and are allowed to grow or shrink. This allows for easy implementation of a Pixel Perfect Printed Product.

Where do these data elements come from, on the left side of the Report Builder we can find the “Datasets” folder and DataSet_Result set.

If we take a look at the Report AL code, we can see where these fields come from.

If we take a look at the Company Name in the green box, we can see how the fields are managed.

Company name is a Text Box element, and we can see all the properties in the properties dialog which we activated earlier. We can set the text color, font, placement location and all sorts of properties. Almost any property can be replaced by an expression, allowing things like element visibility, color, font size, to be managed by data within the report.

We can Right Click on a Text Box element to get it’s text expression.

Here we can see that the content points to a field called CompanyName and its value.

We can include some rather complex expressions here. We can concatenate text, we can perform Boolean operations to select text, we can do math.

The next part of the report the part I boxed in blue is a Tablix. Is it a table? Is it a Matrix? No! It’s a Tablix. I get accused of making up words all the time, but I’m not taking credit for this one.

A Tablix works best when connected to a data set, and in the Tablix properties we can see that it is indeed connected to DataSet_Result.

A Tablix allows you to define rows, columns, row groups and column groups, which is how it pulls off the table/matrix look.

The orange indicator on the left denotes that the column here are part of a row group. This specific row group is grouped by Customer No.

The cells of the table are filled with any of the data elements, but most commonly a Text Box.

Looking at the Text Box that makes up Customer Address Line 2, we can see how an expression can be used to create a text output.

What this reads is: If the length of the CustAddr_2 Value is zero, put an empty string here, else insert a comma and the value of CustAdd_2. This allows it to build out a presentable address one element at a time.

For this report, let’s replace currency with an indicator. First I’ll delete what is in the currency field, then right click and insert an indicator.

I then have to select which kind of indicator, and I’m going with flags.

I’ll then right click on the indicator and select indicator properties.

Then I’m going to select Value and States and configure it like this:

Click OK.

Carefully select the Cell and let’s change the background color to an expression.

=iif(Code.GetRowColor() = TRUE, “#EBEBEB”, “White”)

This generates that alternating gray / white background color effect.

Lastly let’s change the column title by setting the value to “Customer Status”

Save the report, and let’s go back to Business Central Report Layouts.

With the Customer List Report Selected, click the New Button, then fill out the form. Be sure to select RDLC as the report format.

When you click OK you will be prompted to upload your new report layout.

When I run my new report here is the output I get:

As you can see there are a lot of capabilities in the RDLC report system, and we have only scratched the surface. The ability to efficiently utilize expressions for almost any property as well as data values makes these reports very versatile. They also require additional software and a specialized skill set.

We now have a basic understanding of the three reporting systems inside Business Central. So, which one do we use? Here is a breakdown:

Excel Reports: We want to work in Excel, with Excel tables, Excel graphs, Excel pivot tables. We intend to do report data processing inside Excel.

Word Report: We have a document style layout without too much data driven complexity. All the data calculations are performed in AL and delivered to the report completed and ready for layout. Words “squishy” layout and pagination controls are good enough.

RDLC Report: We have complex calculations and layout events that must be handled within the report rending process. We are VERY specific on the layout down to the in, mm, cm, or pt. I was sad when they dropped the twip as a unit of measure.

More information available here Working with RDLC Layouts – Business Central | Microsoft Learn.

I hope you enjoyed learning about RDLC reports. Let me know if you have any questions and thank you for joining me on our 30th step on our AL Journey.

6 responses to “Understanding RDLC Reports in Business Central”

  1. Hi Marcel

    thank you very much for you blog.

    I have one question about rdcl report : is possible to know how many page has been printed ?

    Thanks

    Giuliano

    Like

    1. There are two Global variables you can use in a Header or Footer area.
      Globals.PageNumber and Globals.TotalPages.

      Like

      1. Hi Marcel,

        thanks for the answer but it’n not what i need.

        I need to save the number of page printed for a report because when i print the same report for a different period i should start from the page number printed before

        Best regards

        Giuliano

        Like

      2. Oh! That would be a cool feature, but unfortunately there are several levels of missing communication.
        – Once the report is generated it does not communicate back to Business Central.
        – The printer functions do not communicate back to the reporting system what settings the user applied to the printer.
        – Business Central is unaware of the rendering of the report, so it doesn’t know how many pages the report will be.

        There are some things we can do. When the report is generated in BC, we can write data to a tracking record of what data has been reported. For example the period. When the report is generated again we flag the periods as “Previous”. In the report, we allow for a filter to only show current period or show all. Then you can run and print the current period only as a report addendum or print the complete report.

        Could this work?

        Best,
        Marcel

        Like

      3. HI MARCEL,

        Thanks for your help.

        In old version (nav 2016) i used appdomain class to save data and read on the report (https://community.dynamics.com/forums/thread/details/?threadid=e4cfd83a-bff4-4410-8cfc-8e8781dfd45f) I don’t know if there is something similar that i can use on BC saas.

        Thanks

        Giuliano

        Like

      4. There isn’t a direct replacement for the appdomain that I’ve seen work in SaaS. You could put the report behind a button that prompts the user, but then downloads the report to a stream object, use an Azure Service or an embedded JavaScript control to read the PDF Page Count and update a field in BC for the current page count. I’ve done custom PDF Merge processes, and during the process I had the page count.

        The SaaS world presents a lot of challenges when it comes to security, once the report is generated, it doesn’t want it talking back to BC without authentication.

        Like

Leave a comment

Trending