Data items and columns

Completed

You use a report object in the AL Language development environment to define the data model, or dataset, of a report. The dataset determines the data that is extracted or calculated from the Dynamics 365 Business Central database tables that can be used in a report.

For more information, see Report Object.

You can build the data model of a report from data items. A data item corresponds to a table. When the report runs, each data item is iterated for all records in the underlying table. When a report is based on more than one table, you need to establish a hierarchy of data items to control how the information is collected. You can establish this hierarchy by indenting the data items.

For example, to create a report that prints a list of customers and sales orders that are created by each customer, you need to define:

  • A data item that corresponds to the Customer table.

  • A data item that corresponds to the Sales Order table (this data item is indented).

The report examines all customers in the Customer table and all sales orders in the Sales Order table to find all sales orders that are related to the customer.

You can build the report dataset from data items and columns. A data item is a table. A column can be any of the following entities:

  • A field in a table

  • A variable

  • An expression

  • A caption that is not related to a specific table

Typically, data items and columns correspond to fields in a table. When the report is run, each data item is iterated for all records in the underlying table. Filters are applied and the dataset is created. When a report is based on more than one table, you must set relations between the data items so that you can retrieve and organize the data.

You can also extend a dataset from an existing report, to add more columns for example. For more information, see Report Extension Object.

Using a query in a dataset definition

Instead of building the report dataset directly from tables, you can also use a query object.

To achieve this, you must:

  • Add a global variable that points to the query object.

  • Use an Integer in the data item definition.

  • Add OnPreDataItem and OnAfterGetRecord triggers.