I have a logic which create a parent entity and then use the ID to create child entity.
Let say while looping the child to create them, 1 of them is having a controlled error. So I want to update the Parent column to status invalid.
Can I use the ID from the parent CRUD and call aggregate to update the column and finally update the entity?
All this happen within the same flow.
Hello Aqim,
Yes, you can use ID of parent created record again to update record in same action flow.
But as Arun mentioned its better to update parent record outside loop to implement this update only one time.
You can achieve that by having local variable of data type Boolean for example "HasInvalidChild" and update it value to true inside loop in case one of records is not valid then check this variable outside loop and if it is true implement your update logic for parent record
I see, thank you for the input.
Hi Aqim,
As per your requirement I can understand there will be one to many relationships between parent and child so would suggest you creates records for child only inside the loop and update parent entity outside the loop.
Best
Arun
Alright, thanks for the input.
Yes, you can do that. After using crud you get the ID as the output parameter so you can easily do the required update.
Regards,
Neha
Noted, appreciate the input.