14
Views
6
Comments
Solved
Can I query the ID which is created within the same action flow?

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.

2020-11-25 10-45-32
Mostafa Othman
Champion
Solution

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

UserImage.jpg
Aqim

I see, thank you for the input.

2025-02-10 17-24-13
Arun Rajput

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

UserImage.jpg
Aqim

Alright, thanks for the input.

2022-01-13 11-06-04
Neha Sheikh
Champion

Hi Aqim,

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

UserImage.jpg
Aqim

Noted, appreciate the input.

2020-11-25 10-45-32
Mostafa Othman
Champion
Solution

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

UserImage.jpg
Aqim

I see, thank you for the input.

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