We’ve had recurrent feedback from our developer community that we should aim for a simpler definition of generic lists. For example, to create a list of integers you would need to create a structure that contained a single integer attribute.
This represented a relatively large change in the way we deal with lists, but since it had such a wide impact on your productivity, we decided that with OutSystems Platform 9, we would incrementally improve our type system. And we didn’t want to wait for a major version release to share such an awesome feature with you, so we continued to evolve it. As that evolution came to a natural cut-over point, we deprecated the “old” way of doing it.
If you were used to working with Record Lists, worry not, things aren’t that different now. Let’s check how using Lists is different than Record Lists:
From 9.0 onwards, you can create lists of integers, lists of text, or a list of any other basic type. And it’s as easy as with other programming languages.
To create a list of integers, create a new variable and:
That’s simple right? And that wasn’t possible with Record Lists.
Creating a list of a single compound type like Entity or Structure, was already supported before 9.0.
Until 188.8.131.52, if you wanted to create a list of users, you would create a new variable and:
Now with the List data type, things haven’t changed much. To create a List of Users, you create a new variable and:
The awesome part is that now to access the user’s name, instead of writing Users.Current.User.Name, you can just write Users.Current.Name.
I’ll grant you that this doesn’t seem much for the User entity. But in situations where the names of your Entities, Structures, and Attributes are long, this will save you a few keystrokes and is easier to read.
Oh, and you’ll notice that we’ve also updated the defaults. So, if you name your variable ‘Users’, we automatically define it as being a List of Users.
Sometimes, it’s also handy to define a list of multiple Entities and Structures.
Until 184.108.40.206, to define a list of users and cities you would create a new variable and:
Starting on 220.127.116.11, you can define a List of Users and Cities. Create a new variable and:
Just like for Record Lists, to access the user name of this List, we can use Users.Current.User.Name
And since this approach is more generic, we can even define a List of Users and a Boolean, which we couldn’t define using Record Lists.
When you’re fetching data using Aggregates, they’ll always return a List of Record (just like above). This is because your Aggregates can have calculated or aggregated columns, so they can’t return a list of integers or a list of Entity/Structure.
So if you want to return the result of an Aggregate that fetches users, you might be tempted to define the output parameter as a User List, when in fact you need to define it as a List of Record of User.
Or you can do it the simple way, choosing the suggestion OutSystems Platform gives you.
Can you use records as the datta type for an item attribute? Or do I have to create lists in the database using normalized tables?
I'm not sure what you mean. A record is an in-memory collection of different data types, especially structures. They don't live inside databases.
(Also, your post has little to do with the topic of this thread, and this thread is more than 1.5 years old. Next time please start a new topic.)