One of the most common operations in a data-driven application is fetching and displaying data from the database. Aggregates provide this functionality in the OutSystems Platform.

To fetch data from the database, do the following:

  1. Drag the Aggregate to the application logic, i.e., to an action flow. Aggregates are normally used in the web screen Preparation logic;
  2. Double-click on the aggregate to edit it;
  3. Drag Entities or Static Entities to fetch data from them. You can also drag entity attributes individually.

Once you add an aggregate to your application logic, you can use the fetched data through the aggregate output parameters.

Fetching and Displaying Orders

To create a screen that lists Orders and their status:

  1. Create a new Web Screen, and add a Preparation action to it;
  2. Drag an Aggregate to the Preparation action;
  3. Open the aggregate, and drag the Order entity into it. Notice that since the Order entity has a relationship to the Status and Client entities, these are brought along;
  4. In the web screen, add a Table Records widget and set its property 'Source Record List' with the Aggregate result. The table records is now populated with data fetched from the database;
  5. Finally, drag the Order entity to the table records to display the orders to end-users.

Using Aggregate Results

Once you add an Aggregate to your application logic, you can access the data returned by it through its output parameters.

Each Aggregate has two output parameters:

Hiding and Displaying Columns

Note that some fields (e.g. identifier columns) are automatically hidden in the aggregate, and this fact is shown by a flag with the number of columns that are hidden. These columns are hidden only to facilitate the overview. They still make part of the aggregate, and you can use them the same way as visible columns.

You can choose which columns should be hidden or displayed:

See Also

Filtering Results | Sorting Results | Aggregate Properties