There are situations when the data fetched from the database isn't enough and you need to add more information to each record, namely based on the values returned. OutSystems allows you to do it. You can add new attributes to the records returned by the aggregate based on the value of the other attributes:
- In the aggregate, click New Attribute to add a new attribute to the aggregate and name it.
- Open the attribute menu and select Edit formula...
- Define the expression to calculate the value.
GoOutWeb, a Web App to check interesting places, has a screen to list places.
In this screen, you want to address the following requirement: the end user can filter the listed places by category, by selecting an available category from a Combo Box. In each entry of the Combo Box the app displays the number of places that have that specific category along to the category name.
To calculate this data and add it to each entry of the Combo Box do the following:
Since this is a Web App, add an Aggregate to the screen's preparation.
Placeentity to it.
In the aggregate, do the following:
Place.Idto have the number of places per each category.
Category.Labelto get the label of each category.
Open the last grouped column menu and add a new attribute. Name it
Combo Box Label.
Assign the following expression to the created column:
If ( Label <> "", Label + " (" + Count + ")" , "Not categorized" + " (" + Count + ")" )
Countvariables are two of the previously grouped columns.
Go to the screen and add a Combo Box. Set its values to be the returning list of the new Aggregate.