In my blog post: How Do I : Create a Report, and layout, in VSCode? I explained the basics on how you can create a simple report for Business Central. In this post, and due to many requests, I will explain how you can get started to create a document report.

What is a document report you might think?

Well, a document report is typically a report that you print or generate in pdf to send to a third party, like for example an invoice or a credit note to a customer or a purchase order confirmation to a vendor.

Typically a document report fetches information from multiple tables. In business central, a document, like a sales invoices, mainly stores information in two tables, Sales Invoice Header and Sales Invoice Line, which I will name the Header and the Line table.

The full-Monty of such a report would be report 206 Sales – Invoice or report 1306 Standard Sales – Invoice. In this blog post, I will explain how to get started, to create the dataset, based upon a Header and a Line table. In a later post I will then explain some more bells and whistles that are typically built in to those types of reports.

So, to get started, you can create a new report, name it: MyDocumentReport and add the following code:

In the dataset, I fetch the No. field from the Sales Invoice Header table, rename it to DocumentNo and add it in a data item with the name Header:

This is something I strongly recommend:

  • Give your data item a proper and simple name like: Header
  • Give your fields proper and simple names like: DocumentNo

This will make it easier to spot and find the fields in the layout of the report, as well in the RDLC and in the WORD layouts.

Now you can add more fields from the Header table as columns to the dataset, like for example:

Now we have three fields from the Sales Invoice Header table:

  • No.
  • Bill-to Customer No.
  • Posting Date
Let’s now add another dataitem: Sales Invoice Line and name it Line:
As you can see, the Line dataitem is a part of the Header dataitem. This is because 1 Sales Invoice Header can have multiple Sales Invoice Lines. (Adding a data item inside another dataitem has a similar effect then doing a join between the two tables.)
The link between the two tables is the Document No. field from the Line table and the No. field from the Header table, and you set it in the DataItemLink property: DataItemLink = “Document No.” = field(“No.”);
Now you can add some fields from the Line table:
Our dataset now contains two tables: Header and Line.
Because I’m not interested to see any Headers that do not contain any lines, I will add the following property: PrintOnlyIfDetail = true;
This specifies whether to print data in a report for the parent data item when the child data item does not generate any output.
Using PrintOnlyIfDetail is similar to specifying an INNER JOIN or a LEFT OUTER JOIN in SQL.
Let’s now create a simple layout for this dataset, to see how it renders.

You can do this by adding the property RDLCLayout to the report, and specify the path and filename:

RDLCLayout = ‘MyDocumentReport.rdlc’;

If you now use the AL: Package command, or Ctrl + Shft + B, then the empty rdlc layout file is generated.

Right-click the file and open it externally:
How to create the layout, based upon these two dataitem is what I will explain in my next blog post 😉

One Thought on “How Do I : Create a Document Report, and layout, in VSCode? (part1)

  1. Pingback: How Do I : Create a Document Report, and layout, in VSCode? (part2) – think about IT

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post Navigation