Header Ads Widget

Top Picks

6/recent/ticker-posts

Can I: Add fields to a Report in Business Central?

Yes You can add fields to a Report in Business Central! is the answer

How?

To begin with, a Report object in Business Central includes one dataset and up to three built-in layouts: RDLC, Word, and/or Excel. These layouts are based on the same common dataset. At runtime, you can enhance the report object by adding multiple custom layouts.



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:

  1. Add Columns: Include additional columns to the existing data items in the report dataset.
  2. Add New Data Items: Introduce new data items to the report.
  3. Implement Triggers: Add trigger implementations to the report.
  4. Enhance Request Pages: Modify and add to the request pages.
  5. 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. The OnPreReport and OnPostReport 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 dataset
            column(fromBaseTable; Customer.GLN) { }
            // add field from table extending Customer
            column(fromBaseTableExt; Customer.MyField) { }
        }

        add(Customer)
        {
            // add a new field to the dataset
            column(netWeight; netWeight) { }
        }

        modify(Customer)
        {
            // modify the new, added field
            trigger OnBeforeAfterGetRecord()
            begin
                if (weightInPounds) then begin
                    netWeight := netWeight * 2.2;
                end else begin
                    netWeight := netWeight;
                end;
            end;
        }
    }

    requestpage
    {
        layout
        {
            addafter(Show)
            {
                // add field from table extension to request page
                field(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 trigger
    end;

    trigger OnPostReport()
    begin
        // add code to run after the report is run, will be run after the original report's equivalent trigger
    end;

    var
        netWeight: 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!

    How Do I: Add fields to a Report in Business Central?
    1. What is the default setting for the Extensible property in Business Central reports?
    A) True
    B) False
    C) Undefined
    D) Custom
    Explanation: The default setting for the Extensible property in Business Central reports is True.
    2. Which of the following is NOT a built-in layout type for Business Central reports?
    A) RDLC
    B) Word
    C) Excel
    D) PDF
    Explanation: PDF is not a built-in layout type for Business Central reports.
    3. What is required to make a report extendable in Business Central?
    A) Setting the Extensible property to true
    B) Adding new data items
    C) Implementing triggers
    D) Creating custom layouts
    Explanation: To make a report extendable in Business Central, you need to set the Extensible property to true.
    4. What is generated by typing the shortcut 'treportext' in Visual Studio Code with the AL Language extension?
    A) A new report
    B) A report extension object
    C) A custom layout
    D) A dataset
    Explanation: Typing the shortcut 'treportext' in Visual Studio Code with the AL Language extension generates a report extension object.
    5. Which triggers are supported for report extensions in Business Central?
    A) OnInitReport
    B) OnPreReport and OnPostReport
    C) OnOpenPage
    D) OnClosePage
    Explanation: OnPreReport and OnPostReport triggers are supported for report extensions in Business Central.
    6. Where can new layouts included in a report extension be selected as the default layout?
    A) Report Layouts page in Business Central
    B) Visual Studio Code
    C) Extension Management page
    D) Dataset Configuration page
    Explanation: New layouts included in a report extension can be selected as the default layout on the Report Layouts page in Business Central.
    7. Which shortcut in Visual Studio Code helps with code completion, parameter info, and member lists for AL Language?
    A) Ctrl+C
    B) Ctrl+X
    C) Ctrl+V
    D) Ctrl+Space
    Explanation: Ctrl+Space triggers IntelliSense for assistance with code completion, parameter info, quick info, and member lists in Visual Studio Code.
    8. What must be included in a report extension to add a new field from an extended table to the dataset?
    A) Modify statement
    B) Add statement
    C) Requestpage statement
    D) Layout statement
    Explanation: An Add statement must be included in a report extension to add a new field from an extended table to the dataset.
    9. Which file type is used to define a new layout in an Excel format for a report extension?
    A) .docx
    B) .rdl
    C) .xlsx
    D) .pdf
    Explanation: The .xlsx file type is used to define a new layout in an Excel format for a report extension.
    10. Which property cannot be modified inside the requestpage element in a report extension?
    A) Field properties
    B) Page properties
    C) Request properties
    D) Dataset properties
    Explanation: Inside the requestpage element, you cannot modify any field properties.

    Your score

    Total Questions Attempted: 0

    Correct Answers: 0

    Wrong Answers: 0

    Percentage: 0%

    Post a Comment

    0 Comments

    Youtube Channel Image
    goms tech talks Subscribe To watch more Tech Tutorials
    Subscribe