Yes You can add fields to a Report in Business Central! is the answer
Yes You can add fields to a Report in Business Central! is the answer
How?
You can extend the report and add the new field to the reports which you have
How?
With the report extension object in Business Central, you can enhance existing report objects like extending tables and pages. Report extensions allow you to:
- Add Columns: Include additional columns to the existing data items in the report dataset.
- Add New Data Items: Introduce new data items to the report.
- Implement Triggers: Add trigger implementations to the report.
- Enhance Request Pages: Modify and add to the request pages.
- Add More Report Layouts: Create new report layouts to incorporate fields added via extensions or simply to offer alternative layouts based on the existing report dataset.
For a report to be extendable, the Extensible
property must be set to true
, which is the default setting. This means that reports are inherently extendable unless explicitly marked otherwise by setting the Extensible
property to false
.
From Business Central 2022 release wave 1, report extensions can now have one or more defined layouts. For detailed information, refer to Defining Multiple Report Layouts. Note that while the layout of an existing report cannot be directly extended, you can add new layouts. To use an existing report layout as a starting point, download it from Business Central and include it in your extension project.
New layouts included in a report extension will appear in Business Central as additional layouts for the report. These new layouts are not automatically set as default when the extension is deployed. To use one of these new layouts, navigate to the Report Layouts page in Business Central and select the desired layout as the new Default Layout.
Snippet Support
Using the AL Language extension for Microsoft Dynamics 365 Business Central in Visual Studio Code, typing the shortcut treportext
generates the basic structure for a report extension object.
Use Ctrl+Space
to trigger IntelliSense for assistance with code completion, parameter info, quick info, and member lists. For more information about snippets, see Syntax and Snippets.
Report Extension Example
Below is an example illustrating a simplified table extension that adds a new field, MyField
, to the Customer table. The report extension MyExtension
then incorporates MyField
and another field from the original Customer table into the "Customer - Top 10 List" report. Additionally, it adds a new Excel layout to the report. This example also demonstrates how to modify a new field using the OnBeforeAfterGetRecord
trigger. For a more comprehensive example, see Report Extension Example.
Note:
- Inside the
requestpage
element, you cannot modify any properties. - The
OnInitReport
trigger is not supported for report extensions. TheOnPreReport
andOnPostReport
triggers will run after the original report's equivalent triggers.
reportextension 50110 MyExtension extends "Customer - Top 10 List"{dataset{add(Integer){// add existing field from base table to datasetcolumn(fromBaseTable; Customer.GLN) { }// add field from table extending Customercolumn(fromBaseTableExt; Customer.MyField) { }}add(Customer){// add a new field to the datasetcolumn(netWeight; netWeight) { }}modify(Customer){// modify the new, added fieldtrigger OnBeforeAfterGetRecord()beginif (weightInPounds) then beginnetWeight := netWeight * 2.2;end else beginnetWeight := netWeight;end;end;}}requestpage{layout{addafter(Show){// add field from table extension to request pagefield(fromBaseTableExt; Customer.MyField) { }}}}rendering{layout(MyExcelLayout){Type = Excel;Caption = 'Top 10 customers (Excel)';Summary = 'Top 10 customers in my favorite analysis app: Excel';LayoutFile = 'Top10CustomersAsExcel.xlsx';}}trigger OnPreReport()begin// add code to run before the report is run, will be run after the original report's equivalent triggerend;trigger OnPostReport()begin// add code to run after the report is run, will be run after the original report's equivalent triggerend;varnetWeight: Integer;weightInPounds: Boolean;}
Conclusion and Call to Action
By leveraging report extensions in Business Central, you can significantly enhance and customize your reports to meet specific business needs. Whether you need to add new fields, create custom layouts, or implement additional triggers, the flexibility offered by report extensions ensures that you can tailor reports to your exact requirements.
For more in-depth guidance and practical tips, check out my e-books here. These resources are invaluable for preparing for interviews and creating detailed manuals.
Remember to subscribe to my YouTube channel for more tutorials and insights into Business Central and other technologies. Happy learning!
Your score
Total Questions Attempted: 0
Correct Answers: 0
Wrong Answers: 0
Percentage: 0%
0 Comments