Join two tables and show the description

Join two tables and show the description

  

Hello, I'm trying to join these two tables to reach the end result of the following:

a datable which shows : Data,id_categoria(showing "Peixe" instead of id_Categoria),Numero_paletes.


I've been having alot of trouble with this, searching the webs hasn't really helped me.


hum...

What's the problem? 

The "encomenda" entity has a foreign key to the category.

Just join the tables :)

You do this very easy in an aggregate. Add an aggregate to your logic, drag and drop the "encomenda" entity tobthe aggregate and than drag and drop again the "categoria" entity. The koin will be made forbyou and now you have all the fields you need...

Cheers

Eduardo Jauch

Hi Paulo,

building on what Eduardo wrote, Aggregates allow you to do this in a very straightforward way:

  1. Create and empty Aggregate (drag an Aggregate Tool to your action flow);
  2. Open the Aggregate and drag the Encomenda entity to it;
  3. Drag the Categoria entity to the Aggregate as well (anywhere will be fine);
  4. You should end up with an Aggregate that has the contents of both tables joined with Join condition Encomenda.id_Categoria = Categoria.id_categoria.

Aggregates are automatically optimised by the platform if they're directly used on a Screen, so you don't need to worry about fetching only the fields you'll actually want to display.


I had to make the join by hand it didn't create it automatically, it dosen't do anything.



Hi João,

If the join was not made automatically, this means that you don't have a relationship between those two tables.
To have a relationship, you need to set the foreign key (FK) to be of type YourEntity Identifier.

In this case, in your data model, the field id_Categoria in the entity Encomenda should be of type "Categoria Identifier".

This way you are creating a relationship between those two entities, and the "id_categoria" in the table Categoria becomes unnecessary (as the id_categoria in Encomenda will point to the id field in the Categoria entity). 

And the join is made automatically for you, when you add the Category to an Aggregate that has the entity Encomenda.

Also, you need to drag the fields (from Encomenda and Category entities) that you want to see in the Table Records, to the Table Records.

May I ask you if you finish already the Online Training?  All this information is given there. If you didn't finished it, or don't remember, would be good for you to finish it.

Cheers,
Eduardo Jauch

it shows this when i load encomenda into the tablerecord, it shouldn't show carne, but peixe


But you are correct i haven't even realized there really was online training, i will check it out, thank you!

Solution

Paulo Januário wrote:

it shows this when i load encomenda into the tablerecord, it shouldn't show carne, but peixe


But you are correct i haven't even realized there really was online training, i will check it out, thank you!

Hello Paulo,

Two things here.

First, what you see in the Table Records, in the screen, in the development environment, is just an "example". It is not what will be shown when the application is running.

Second, you didn't setup any filter in the aggregate, so you will fetch all information from the entities...

Cheers,
Eduardo Jauch


Solution

Thank you very much for your patience I have figured it out, you were right! I needed to check the actual program running.

Always glad to help. :)
The online training (or a live course) is a good idea. Even for OutSystems.

Cheers,
Eduardo Jauch