Iterate through a structure of structures

Iterate through a structure of structures



So, this came up to project. Although I've ended up going a separate way, it got me thinking if it is possible to do it in outsystems.

The goal was to write to a specific excel file. This excel file was divided into multiple sheets, each sheets had 3 tables (lets call them "departments" and, each table multiple rows (such as department profit / costs / sales) and multiple columns (such as a person1, person2 and so on).

This had to be reused multiple times so I've created some static entities (ExcelSheets;Departments;IncomeType;Persons) and multiple structures child / parents between them so it follows the logic on the Excel file we had to fill out.

This way, if we wanted the value of a specific cell we would just need to call it's logic value on the structure:


Is there anyway to iterate through a structure like this in OutSystems. Ideal we would be able to build a tree of foreachs and run trough the values of the multiple static entities and call out a specific value. Such as:


Is this possible? I've ended up using a solution with specific methods and a lot of switch. However something similar to the one above would be a lot more DRY and less prone to bugs.

Thank you in advance

Hi Hugo,

If your structure has an attribute defined as a list of another structure, compound object or basic type you can iterate over it using the foreach action.

For static entities, you can use an aggregate and then iterate over the records in the static entity.