Fetch data using an optimized query. Aggregates can load data from the server of the local database, and they support combining several Entities and advanced filtering.
We've been working on this article. Please let us know how useful this new version is by voting.
Client-side Aggregates run in the client logic. Use them to get data for your widgets when a Screen or a Block loads. Follow the steps:
Right-click a Screen or a Block and select Fetch data from Database. An empty Aggregate opens, and Service Studio shows that you need to add an Entity.
With the Aggregate still open, navigate to Data > Entities > Database.
Drag one of the Entities to the Aggregate window. Service Studio populates the Aggregate with columns that correspond to the attributes of the Entity. Note also the name change; if your Entity is MyEntity, the Aggregate gets the name GetMyEntity.
Go back to your Screen or Block and set an element to use the data. For example, if you have a List widget, set the Source of the List widget to GetMyEntity.List. You can always double-click an Aggregate to add more Entities, join data, or create filters.
Aggregates that run in the server-side logic are in the logic flows. To add an Aggregate in the server logic, drag an Aggregate from the toolbox to the flow of an action.
Notes on Max. Records and zero value
The Max. Records property in Aggregates controls the maximum number of records the Aggregate returns. Max. Records property works slightly different in client actions and server actions when you set the value to zero (Max. Records = 0).
- In the server actions, Max. Records = 0 returns all records from database.
- In the client actions, Max. Records = 0 returns zero records from database. Additionally, Max. Records is mandatory in Reactive Web and Mobile Apps in Screens/Blocks and client actions. This helps you control the amount of data the Aggregate returns and avoid performance issues.
Setting Max. Records to zero works like this in other elements that reuse Aggregates to get data, for example Refresh Data.
Traditional Web Apps
In Traditional Web Apps, Aggregates run on the server, so you can only add server-side Aggregates.
To load data when the screen loads in Traditional Web Apps, place an Aggregate in the Preparation action (right-click a screen add select Add Preparation.). Preparation exists in Traditional Web Apps only.
|Name||Identifies an element in the scope where it is defined, like a screen, action, or module.||Yes|
|Description||Text that documents the element.||Useful for documentation purpose.
The maximum size of this property is 2000 characters.
|Timeout||Maximum time in seconds to wait for the Aggregate to return data before triggering a Communication Exception. Overrides the default timeout defined on the module.||If there is no value specified in this property, the timeout corresponds to the "Default query timeout" parameter specified in the Platform Server Configuration Tool.
Property not available in client actions.
|Cache in Minutes||Maximum time content or results are stored in memory. When undefined, nothing is cached.||Property not available in client actions.|
|Max. Records||Maximum number of records read from the database.||If undefined, the default value is:
– In widgets: StartIndex + LineCount + 1;
– Exporting to Excel: No limit.
|Start Index||Index of the first List item to iterate. Can be an expression.||The expression used in this property (if present) is evaluated before the web screen preparation.|
|On After Fetch||Action executed after the aggregate fetches data from the data source.|
|List||Collection of records returned by the performed query.||Record List|
|Count||Number of records returned by the Count query.||Long Integer|
|IsDataFetched||True when data has been fetched from the database and is ready to be used.||Yes||Boolean|
|HasFetchError||True when there is an error during data fetch due to a server error or communication timeout.||Yes||Boolean|