Complex Data Structure with Outsystems

Complex Data Structure with Outsystems

  

It is possible to create a complex data structure in Outsystems? 

for example I have several labels/fields that require multiple inputs. for example

a attribute named actual budget needs to have three inputs in a form (actual, budget, variance). I need to create a form where I can do this type of input. is it possible?


Hello Jeremy.


Sure it it! I'm guessing that you have a filed for each in your entity, to where you'll be saving that data. It's also likely that your form has a source with the entity as a type. You can then bind each form field with a particular attribute of that variable. You're getting me?

Hello Jeremy,

Just to complement Pedro's answer, I would like to point a few things.

In OutSystems, you can have complex structures, where a structure attribute can have a complex type (being another structure, or a record, for example).

But the entities (the tables), can't have complex types. 

So, if you are storing the information in the database, ex, a table with three fields called actual, budget and variance, the only thing you need to do in the form is to drag and drop those three fields to it.
Or, if you want to put them in the same row, just give a label, like budget (or whatever), and then the 3 input one after the other, each one bound to the correct field.

Cheers,

Eduardo

Thanks Eduardo :)

Thank you for the replies.

I understand what you guys explained. I did something similar with an editable table. In a way it works. However, I have to add a "New" line for every field when I want to input something new. It works but the goal is to have it as a form to serve as a "Template". The error I get when I do it in the form is "You are using the same variable twice". I assume that if in the form I could somehow attach the Id of the label next to the input field to the appropriate variable it could work. I just can't figure out that part in outsystes yet. for example, if I have an entity called Money, and an attribute called values. Inside of Values I have a column of names as shown below, and then I have the Actual, Budget, etc. I want, in the form to do something like the following...

Money.Values.Car Money.Actual

The end goal is to have a template so that the user can just input the data instead of having to add a new field and then add the input. If there is a different way of doing his with another widget then I am open to suggestions. The key feature it must have is "Versions" so, for example, the approach I am doing with the editable table works but if the user wants to inout a new version it would either overwrite the previouse one or the user would have to ass the same ammount of fields again to avoid overwriting.


Solution

Hello Jeremy,

I'm not sure I completely understood you, but I think this is not how things work...

"if I have an entity called Money, and an attribute called values. Inside of Values I have a column of names as shown below, and then I have the Actual, Budget, etc. I want, in the form to do something like the following...

Money.Values.Car Money.Actual"

See, an entity does not work like this.
An entity has attributes, and an attribute must be a "simple" data type, like an integer, or a text, or an identifier. An attribute of an entity can't be of a complex data type.

So, if you want to save in database 3 different values for the "car money", you will have to really create 3 fields in the entity for that. like car_money_value_actual, car_money_value_budget, car_money_value_whatever.

The Label is another story. You can have a Label in form, and the label can be connected to a SINGLE input. This means that if you click the label, it will focus the input it is bound, and if the input is mandatory, the label will show a red asterisk. Because this, you can't have the label connected to more than one input.

If you want to do a "dynamic" form, that will show inputs depending on a configuration, than you will have to use other techniques, like put a list in the screen, and infer the data type of the input for each line and use a web block to show the input bound to variables and use the notifies and so on. (probably there are easier methods to do that, but I fail to see them at this moment).

Cheers,
Eduardo Jauch


Solution

Hey Jeremy.


I'm sorry but I'm struggling to understand what you want to achieve. Are you able to describe what you're trying to achieve with a real use case? Maybe it could help...

Pedro Cardoso wrote:

Hey Jeremy.


I'm sorry but I'm struggling to understand what you want to achieve. Are you able to describe what you're trying to achieve with a real use case? Maybe it could help...


Thanks for the reply,

I come from a more programming oriented background and I was trying to implement somethign similar to a complex data structure in outsystems. I did managed to do something similar that seems to be working. what I was trying to do is something that in a programming language you would do like this...


If I have residential properties... Apartment and house and they have addresses, residents, prices, etc I want to place data specifically to a residential property like this..


Residential Property. apartment.resident.name.first name


Hello again Jeremy. I was out in vacations so I didn't get your last reply until now.


I guess you're referring to "object oriented programming", correct? I can understand that in a language with such constructions you would have a couple of objects named ResidentialProperty and Apartment, and an Apartment would have some properties like name, etc. A residential property would contain a collection of apartments. Does that sounds ok?

Even though you would have that in your OOP, you would somehow need to persist those objects to a database. When doing so, you would probably have a table of properties and a table of apartments, with a column propertyId so that you could identify which apartments belong to the same property.


Good news is it is the same with OutSystems! We just named them entities. And you don't need to spawn objects to carry the info on properties and apartments by hand. It's all simplified. You just grab them from the database, work with them as they were objects, and then save them again to the database.


Hope it helps!