Creating a related record.

Creating a related record.

  
Hi All,

I'm new to agile development and need some help. I'm trying to create a related record from TableOne to TableTwo. From the 'Save' action on the TableOneEdit screen I've tried adding the 'CreateOrUpdateTableTwo' action to push the table one field value to  table two, but not having much luck. I've attached a sample Application if someone can update it to show how this is done. Tried looking at the online tutorials, I can't seem to find one on this. Any help would be appreciated!

Thanks.
Bruce.
Hi Bruce,

I'm not sure I fully understand what you want to accomplish but I think you want to create an identical record in TableTwo when you are creating a new record in TableOne?

In this case it's all about typechecking. That's one of the reasons the OutSystems platform can produce such robust applications.

So to answer your question (at least my interpretation of it):

- if you want to use a CreateOrUpdateTableTwo action in the logic of your TableOne_Edit webscreen you need to add a local TableTwo Record to the TableOne_Edit webscreen

- After you have done that, you do the following in the logic of the TableOne_Edit webscreen:
  • assign the FieldOne attribute of the TableOneEdit widget to the FieldOne attribute of the local TableTwo Record
  • execute the CreateOrUpdateTableTwo action with the local TableTwo Record as it's source

I've attached my solution so you can see for yourself. It's not bulletproof though: it only works 100% when you start with empty TableOne and TableTwo tables AND the start-id of both tables has to be the same (which problably is not the case if you already have been trying things in your application).  The thing is that you are not supposed to try to give the id of a table a value yourself, it's done automatically. That's why I started with the remark that I don't fully understand your question.

Nevertheless, I hope this helps you in the right direction.

Regards,

Peter
Hi Peter,

Thanks very much for the response! The example you sent back is great, it works just as I need it to. I was missing the "add a local TableTwo Record to the TableOne_Edit webscreen". I was trying to map 'Data Type - Text  imput variables and not 'Record' type, it seems that 'Record' type exposes all of the table columns.
 
I appreciate your help!

Thanks Again!

Bruce.
Hi Bruce, and welcom to our community forums.

I'm glad to see that you got this problem sorted out - thanks Peter, for helping out!

Do let us know if you bump into something else, everyone's here to help.

Regards,

Paulo Tavares
HI, I Have a two table, in the save button action i want to insert the record into first table and trying to get the id of the last inserted record to update the second table record, but i am not able to get the id of first table in the save action to update the seceond table

Thanks
Rajendra.
Hi rajendra,

The new id an output parameter of the Create or CreateOrUpdate action that you used to insert.

Regards,
João Rosado
Hi,

Maybe this video on how to change and refresh a row on a list can help you.