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:
- Drag the Aggregate to the application logic, i.e., to an action
flow. Aggregates are normally used in the web screen Preparation logic;
- Double-click on the aggregate to edit it;
- Drag Entities or Static
Entities to fetch data from them. You can also drag entity attributes
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:
- Create a new Web
Screen, and add a Preparation action to it;
- Drag an Aggregate to the Preparation action;
- 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;
- 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;
- 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:
- List: contains the list
returned from the database. If there are no results, then the list
- Count: contains the number of records returned by the aggregate.
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:
- Click on the flag to show hidden columns;
- Click on and choose 'Hide' to hide specific
Filtering Results | Sorting
Results | Aggregate Properties