I am beginner to Outsystem. I am exposing a rest Api . In that i am using complex structure i.e. structure inside a structure.
i want to insert the child structure into entity. That child structure contain multiple rows .I assigned that structure to aggregate and used ''for each' component to insert data but it inserted only the last row.
plz suggest me the better way
Hi Nilam,
As per the API method Input parameter structure definition, both EmpBankInfo and EmpBankInst are structure type and entity type record placeholder, it means that at an instance the placeholder can only contain a single record
If your objective is to feed/pass multiple bank account detail for a single newly created employee, I would suggest you to change the EmpBankInfo placeholder type from structure record type to List type placeholder as implemented in the the attached .oml file
Please refer the attached .oml file
Regards,
Benjith Sam
Thanks Benjith Sam ,
It works. changing the data type of structure to structure List solved the iteration issue.
i appreciate your help.
Thank again.
As per my understanding the implemented approach which you followed is correct for the mentioned objective but I got bit confused in understating this statement -> 'I assigned that structure to aggregate'
If possible could you please share the .oml file with us to get a better understanding of your implementation?
Thanks for the reply.
i wants to insert all rows of that structure into the entity. to which component i should assign that structure so that i can use 'for each' to iterate all rows.
I have checked your oml file, in that no need of for each loop to create a single record you just need to put Create or update Emp bank info like below:
Hope it will help you!!
Regards,Krushna
Krushana Mantri wrote:
i tried this but only last record inserted. i have 3 rows in bank details structure.
After observing the implementation in the shared .oml file, I assume that using the exposed API action and it's input parameter value, you are trying to create a New Employee Record in the Employee Entity and the related employee's bank account details in the EmpBankInfo entity.
Benjith Sam wrote:
json is like
{
"Name": "Nil112",
"Email": "nil112@outsystems.com",
"Gender": "Male",
"City": "Linda-a-Velha",
"State": "Lisbon",
"Country": "Portugal",
"Occupation": "OutSystems Community Mascot",
"EmpBankInst": {
"empId": 1234567891234567,
"BankName": "w2w",
"BranchName": "r2r",
"AccountNo": "t2t"
},
"empId": 35535,
"BankName": "ww2w",
"BranchName": "r2rr",
"AccountNo": "t2tt"
}
as per the Sample JSON, you are sending multiple Bank info so the input parameter of API should have a
list of EMP Bank structure like below
then you can iterate that list and create new Bank Infos like below
hope that will help you, find attached oml for your referencece
Krushna
Thanks Krushana,