Use a snippet to create a report object

Completed

Entering the shortcut treport will create the basic layout for a report object when you're using the AL Extension feature in Visual Studio Code.

The following example shows the sample logic from using the treport shortcut.

report Id MyReport
{
    UsageCategory = ReportsAndAnalysis;
    ApplicationArea = All;
    DefaultRenderingLayout = LayoutName;
    
    dataset
    {
        dataitem(DataItemName; SourceTableName)
        {
            column(ColumnName; SourceFieldName)
            {
                
            }
        }
    }
    
    requestpage
    {
        layout
        {
            area(Content)
            {
                group(GroupName)
                {
                    field(Name; SourceExpression)
                    {
                        ApplicationArea = All;
                        
                    }
                }
            }
        }
    
        actions
        {
            area(processing)
            {
                action(ActionName)
                {
                    ApplicationArea = All;
                    
                }
            }
        }
    }
    
    rendering
    {
        layout(LayoutName)
        {
            Type = RDLC;
            LayoutFile = 'mylayout.rdl';
        }
    }
    
    var
        myInt: Integer;
} 

The treport snippet creates the skeleton of a report object. It contains the following report components:

  • Report properties

  • Dataset

  • Request page

  • Rendering

  • Global variables

For an overview of the available report properties, see Report Properties.

You can use the Ctrl+Space keyboard shortcut in Visual Studio Code to get an overview of the available report properties.

Screenshot of the overview of available report properties.

The dataset is located below the properties. The dataset of a report contains the data items. You can add one or multiple data items to a report. Use the tdataitem snippet to add a data item to a report.

        dataitem(DataItemName; SourceTableName)
        {
            column(ColumnName; SourceFieldName)
            {

            }
        }

A data item contains one or more columns. Use the tcolumn snippet to add a column to a data item, as follows:

            column(ColumnName; SourceFieldName)
            {

            }

The Request page is below the dataset. After the Request page, is the rendering section. In the rendering section, you can define one or multiple layouts for the report.

After the rendering section, there’s the var section, where you can declare global variables and procedures.