Form that inserts in 2 tables of data
Question

Hi guys so I am building my first project and I'm having some problems because i want to create a form where i can see and edit  data from two tables in the images we have the form then the two tables.

Hi Nuno Couto,

You need to create a structure that has attributes from both entity (The attributes you want update, create) and give this structure to the source of your form and  while saving an application you  need to assign the captured data and after that use create and update action of each entity,

Hope this will help,

Regards,

Komal

Hi Nuno,

Here I have attached OML to create and update data from 2 entities , you can find it under Form Screen,

Kind Regards,


FormDemo.oml

Hi, friend!

Traditional or Reactive?

You need to use a custom structure to hold both tables data and then assign each one on the CRUD. Something like this:


Just be careful to do not abuse the scope with many attributes. The local variable with type MyStructure will be assigned to the form.

Its a tradition project

Create a new local variable with type "MyStructure".

On the preparation, fill the data (if needed).

On save action, assign the data to each entity to be saved.


If something is not clear, send here :)

So lets see if i get it 

I already have my two table then i create a struture where i can put the two tables then use that structure in the form its that ?

But how i put the tables in the structure?


Hi Nuno,

You don't need to create a structure, just use the entities strucutre:

  1. On the preparation add a query to fetch the entities with a join cadidatura.Id_candidato = user.id,  MaxRecords = 1 and the Candidatura.Id = IdInput
  2. On the form put the source Query.current (after that both entities will be available in the form)
  3. On the save action use the form record to save the data in the database

Don't worry about performance, since the platform when using aggregates only uses the fields used in the form.

Don't forget to use the form record in the save and not the query.

Hope it helps,

Ricardo Pisco.

Hi Nuno,

Could you please share your OML to understand your data structure and provide you the solution?

Thanks & Kind Regards,

Sachin 

Hi Nuno,


If  I'm understanding your problem, the solution is very simple:

  1. On the preparation add a query to fetch the entities with a join cadidatura.Id_candidato = user.id,  MaxRecords = 1 and the Candidatura.Id = IdInput
  2. On the form put the source Query.current (after that both entities will be available in the form)
  3. On the save action use the form record to save the data in the database

Don't worry about performance, since the platform when using aggregates only uses the fields used in the form.

Don't forget to use the form record in the save and not the query.

Hope it helps,

Ricardo Pisco.

Champion

Hi Nuno,

Do you want to change the items retrieved from the user table such as name and email address?

Or only to display in the form?

 Kind Regards,

Sachin 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.