Insert a record in several entities

Insert a record in several entities

Suppose I have four entities related each other like this:

Table 1 : Categories
Id (PK) Name

Table 2 : Ideas
Id (PK) Name

Table 3: PointsType
Id (PK) Description
Points (int)

Table 4: States
Id (PK)

And The Relations :
Table 5: IdeaCategories
Id (PK)
IdeaId (FK)

Table 6: IdeaPoints
Id (PK)
IdeaId (FK)

Table 7:
IdeaStates (To Save History)
Id (PK)
IdeaId (FK) StateId(FK)

I Have a eSpace with a Edit Record and I Want to Insert all this data in several Entities when I press the Save Button.
What is the best way to do this? using Action Entities? An advanced Query?

Hello Rui,

First of all, welcome to the OutSystems Community!

Regarding your doubt, you can in fact assign several entities to one Edit Record or you can set each entity in a single Edit Record. I would prefer to split the entities by several Edit Records accordingly to their context.
To assign several entities to one single Edit Record, you can use the "source record" of the widget (assigning a query to it), or you can edit it in the "record definition" (selecting the option Record Editor).

To store the Edit Record content in the DB, you can just use the Entity Actions (available on the left side of the canvas) CreateOrUpdate<Entity> or Create<Entity>.

Just a hint, please make sure to set the foreign keys' value in the Edit Record (with the returned value of the function Create<Entity> or CreateOrUpdate<Entity>) when inserting a new entity and a new relation (for e.g., when storing a new Idea and a new IdeaPoints).

José Martins