How To Create A Report Extension To Add A Field To The Dataset Of A Report

Overview

In the report extension, you can extend existing reports, similar to tables and pages.

Some of the features in the report extension 

Adding columns to the existing Dataitem.

Adding new Dataitem.

Adding a new layout file which reflects with new fields of report extension.

Adding fields in the request page.

For instance:

Let’s add a field in the Sales Invoice NA report 10074.

Add a field [HalfQty] in the existing report.

First, we need to create new “al file” for report extension. In the file, we can use report extension snippet “treportext” to create report extension object. Then we give ID and NAME for our report extension object and add a field [HalfQty] in the dataset. Report extension layout: Next step is to add a layout file to the report extension. Because when we add the property [Rdlc Layout / Word Layout] to report extension, then it automatically creates a layout file of report extension, which will be empty, so we will not use this recreated file, but instead we will use a base layout file. So, how to find a base layout file! We need to go to “Business Central” and search the “Report Layout Selection” page and then filter it on “REPORT ID[10074]” as shown below. Now we will add a new “Custom Layout” for the report, that’s a copy of Built-In Layout (Same as shown in below): Click on the “Custom Layouts” and Open the Page then select the “New”. Once when we click on “OK”, It will Create a copy of Build-In Layout. (As shown on above). Now we can “Export” it (As shown in below). Then file [.rdlc] is download and now we need to the move exported file [Copy of Build-In Layout] in our Vs-Code project folder and rename it to “SalesInvoiceNAExt.rdlc(As per choice): And now we are adding our field in the layout file. So, we will Compile “Ctrl+Shift+B” in the project, then new added field “HalfQty” in the dataset of the report extension will also be added in the rdlc layout. When we open the rdlc layout in Vs-Code, we will have the updated dataset and Copy of Build-In layout: Next, we need to publish the project [App] in BC. Update the New [Copy of Build-In] Layout in Business Central: Now we will again open the “Report Layout Selection” page and deploy our new layout in Business Central. Go to “custom layout page” then “Import Layout” and after import then Update it (as shown in below): After updating, the layout is showed in the page, set this layout as a default layout in this page because the layout of report extension is not updated automatically. Always make sure to choose “Default Report Layout”, once done, then test it.

For more details kindly visit our LinkedIn page:

https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/

or you can write us on  contact@allgrowtech.com

Facebook
Twitter
LinkedIn

By Aditya. D.

Author

Leave a comment

Your email address will not be published. Required fields are marked *