Add multiple records in child table after inserting parent table record

Add multiple records in child table after inserting parent table record

  

Hello,

I have two entities -  Meeting and Meeting_Instances.

Meeting

  • MeetingId (PK)
  • Title
  • Occurance (Number)
  • StartDate
  • other attributes ...

Meeting_Instances

  • Meeting_InstancesId (PK)
  • MeetingId (FK)
  • Date { which is calculated for each occurrence weekly from StartDate }
  • other attributes ...

Requirement

I have created a MeetingDetails page, which inserts a record in Meeting table on Save Action.

On the same Save action, after adding Meeting record, I need to insert Meeting_Instances records 'Occurrence' number of times. using calculated Date, and Meeting.Id.



Hi Deevan,

I suggest you use a variable with a loop, like this: 

Does this do the trick for you?

Wouter.

Hi wonder, 

Thanks for reply, 

I am very new to outsystems, let me try this solution. 


Thanks again 

Hi,

I understood the logic flow, just wondering how to "Set Attributes for MeetingInstances" in "Assign".

how to take a blank entity if MeetingInstance and fill it with variables.

Deevan wrote:

Hi,

I understood the logic flow, just wondering how to "Set Attributes for MeetingInstances" in "Assign".

how to take a blank entity if MeetingInstance and fill it with variables.

I figure out a way, please correct me if I am doing bad coding practice.

I took a Blank Form and set source record property to MeetingInstance to get first meeting record,

and i use that record in "Assign" and overwrite all required value and set Id = NullIdentifire()

which allows me to insert new record in child table.




I don't think you need to use a Blank Form and do something with source record property.

An working example is in the attachment.

T.b.h. this is all pretty basic Outsystems programming. My guess is you haven't completed the basic training yet? See http://www.outsystems.com/learn/ for some very educational video courses. Really worthwhile...

Regards,

Wouter.


Hi Wouter,


thanks for reply, i have done this...

I have created a local variable of type MeetingInstance, and filled it as per my requirement, 

and this worked for me..


Thanks, i really appreciate your efforts.