Today I want to introduce a common OutSystems design pattern that I used my Rapid Outdoor Map App Prototype that I wrote in 90 minutes. There are a few of these patterns that can be challenging to come up with when implementing them for the first time. Over a few articles, I want to introduce some of these less intuitive patterns.
Companies like STEMCELL were quick to react to COVID-19 and built an employee monitoring app called “My Status” with OutSytems in a single day. (A version of this app is available on the OutSystems Forge.) On April 25, during the virtual OutSystems Live Tokyo event, I introduced how to build such an app in an hour.
One common requirement for employee apps is a dashboard with a table showing each employee and the latest associated record. This type of dashboard also should indicate which employees haven’t entered a report. Here is a simplified sketch of what that looks like when implementing COVID-19 apps using OutSystems:
The data model behind this type of app is some master records with status records associated with a 1:N relationship.
When I wrote my map app, I encountered this pattern in another form. I wanted to display a list of locations with the latest picture as a thumbnail. For locations without a picture, I wanted to show a camera icon. Here is a screenshot of what that looks like:
It sounds straight forward, but there’s a trick if I take the maximum of
Picture.CreatedOn and add a group filter on
Picture.CreatedOn = Picture.CreatedOnMax, results where there is no picture are excluded from the result because
null. If we go back to the example of the employee health reporting app, we won’t display people who aren’t monitoring their health, which is the group of most concern. To get around this issue, I create a calculated attribute called
CreatedOnOrNow and set the formula to
If(Picture.Id<>NullIdentifier(), Picture.CreatedOn, CurrDate()).
To get the latest record (employee report, thumbnail picture, etc.) associated with parent records (employees, locations, etc.), create a calculated attribute that holds a dummy value. By doing this, all parent records are returned and displayed.