I have been working with OutSystems for over a year, but I have trained new developers in the last 10. I can assure you I have never worked with a software development tool as powerful and as easy to learn as Outsystems… but…
I think I know very well OutSystems training materials, I use them almost every day, and some slides I even know them by heart.
A few weeks ago, one trainee came to me and asked, “Why should I use structures in an aggregate if they don’t have any data inside?”
My answer was something like: “Can you?”
But in reality, you can also mark a Structure as a Source:
However, if the structure (1) doesn’t have any data, and (2) the columns don’t even appear in the preview, the question is: Why?
Yet, it can store temporary data in those attributes left by the structure, extra attributes that can be used in the User Interface.
Structures are handled as Sources in an Aggregate because they are useful for the Aggregate to generate the SQL query. The SQL query result will include some extra null columns, like in the example below:
SELECT TOP (32) NULL o0, NULL o1, NULL o2, NULL o3, [ENEVENT].[ID] o4, [ENEVENT].[NAME] o5, [ENEVENT].[LOCAL] o6, [ENEVENT].[DATE] o7, [ENEVENT].[EVENTTYPE] o8, [ENEVENTTYPE].[ID] o9, [ENEVENTTYPE].[DESCRIPTION] o10
FROM ([OUTSYSTEMS].DBO.[OSUSR_BHT_EVENT] [ENEVENT]
Left JOIN [OUTSYSTEMS].DBO.[OSUSR_BHT_EVENTTYPE] [ENEVENTTYPE] ON ([ENEVENT].[EVENTTYPE] = [ENEVENTTYPE].[ID]))
Using debug tools, you can see that at runtime, the aggregate now has 4 new “columns” containing default values.
Furthermore, those new fields can store data about particular rows in the list.
In the image above, you can see the usage of that boolean value to manipulate the color in an If widget. At this example, the two If widgets have the conditions: “EventTable.List.Current.CRUD.HasUpdated”, and, “EventTable.List.Current.CRUD.HasDeleted”, respectively.
To manipulate these values, you can use Check Boxes with the variable property set to "EventTable.List.Current.CRUD.HasUpdated” and “EventTable.List.Current.CRUD.HasDeleted”.
In the image below, you can see that if you select one Check Box, the value of that particular item on the list will change:
We must realize something… the items saved on that CRUD structure are just data saved on the widget list and are not persisted in the database. If you want to save or use that data in the future, you need to save it somewhere and remember that you don’t have an entity in the database for that. As soon as you refresh the screen, you will lose all that information.
Remember, learning OutSystems can be very rewarding. But it helps if you fall in love with the platform! The second you and OutSystems meet each other very intimately, you will understand its behavior.
Say hello to the future!
I can assure you I have never worked with a software development tool as powerful and as easy to learn as Outsystems.