We want to create a report for our extension that prints the list of Customer Categories, and for every category, the number of associated customers. To create a report in AL,  we will use the file called Rpt50100-CustomerCategoryList.al. In this file, we use the treport snippet to create the report structure: Rep50100We need to define the report dataset by defining the data item and the associated fields. In the report definition, we set two properties (RDLCLayout and WordLayout) that define the folders where the RDLC and word layout for this report are defined (here we have created a Layout folder under our project):


In the OnAfterGetRecord trigger of the report’s data item, we calculate the FlowField returning the number of customers associated with the current category. Our report definition is as follows:
report 50100 CustomerCategoryList { //DefaultLayout = Word; RDLCLayout = ‘Layout\CustomerCategoryListRDLC.rdl’; WordLayout = ‘Layout\CustomerCategoryListWord.docx’; UsageCategory = ReportsAndAnalysis; ApplicationArea = All; Caption=’Customer Category List’; dataset { dataitem(CustomerCategory; “Customer Category”) { column(No;No) {} column(Description;Description) {} column(TotalCustomersForCategory;TotalCustomersForCategory) {} column(FreeGiftsAvailable;FreeGiftsAvailable) {} trigger OnAfterGetRecord() var begin CalcFields(TotalCustomersForCategory); end; } } }
If we build the report (Ctrl + Shift + B), we can see that in the Layout folder, we now have two files added (.rdl and .docx) that are the report layouts:


Now we can customize the layout by using standard tools such as Microsoft Word (for Word layout reports) or Report Builder (for RDLC reports). We can open, for example, the .rdl file with SQL Server Report Builder, and from this tool we can see the dataset and its fields and we can customize the layout how we want. From this point, this is exactly the same work as designing a report for Microsoft Dynamics NAV or any other RDLC report in SQL Server:


When you publish the extension (by pressing F5) to your Sandbox environment, the report and its layout are embedded into the app file and loaded into Dynamics 365 Business Central (NAV App Object Metadata table).

Tech Support from Navisiontech… On-Demand and On Point

Try Navisiontech Support today! We offer 2 FREE hours of support for nearly ALL versions of Dynamics NAV, from version 3 to Business Central. Our support team is US based and will provide support not only for your ERP system, but also for SQL Server, EDI, supply chain management tools, and even code-level support.