# Nested iterations on objects

**URL:** <https://community.appfarm.io/t/nested-iterations-on-objects/1454>\
**Category:** Ask the community\
**Tags:** app-data, actions\
**Created:** [October 17, 2024, 1:24pm UTC](https://community.appfarm.io/t/nested-iterations-on-objects/1454 "2024-10-17T13:24:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oystein\_Selbekk](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/oystein_selbekk/32/1677_2.png) [@Oystein\_Selbekk](https://community.appfarm.io/u/Oystein_Selbekk)\
**Post date:** [October 17, 2024, 1:24pm UTC](https://community.appfarm.io/t/nested-iterations-on-objects/1454/1 "2024-10-17T13:24:49Z")

</div>

Hi guys. I am trying to update an object in the first iteration with values from the second iteration as shown in the image below:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/7/76b94c5b85b85dcf9acf1297b71f2cd64a615eb8.png)  
I have added a few debugging details in the log that indicates that the first iteration and the second one is both correct. However, when i try to update the “Parent” object in the selection which is done in the first iteration, it seems like its updating from the object also in the first iteration. I might be approaching this from the wrong direction, but how can I make sure its updating from the correct iteration?  
Or is there a better way to do this?  
Please advice on how to proceed.

Øystein

---

<div class="post-metadata">

**Author:** ![kristian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/kristian/32/58_2.png) [@kristian](https://community.appfarm.io/u/kristian)\
**Post date:** [October 17, 2024, 8:39pm UTC](https://community.appfarm.io/t/nested-iterations-on-objects/1454/2 "2024-10-17T20:39:47Z")

</div>

Hi!

I don’t think it will work to iterate the same datasource in a double Foreach. Reason: it will then need 2 contexts / have 2 objects in context in the inner loop. Not sure which context it uses, but it makes sense to me that it does not work.

Suggestion: use two different data sources for the two iteration levels!

---

<div class="post-metadata">

**Author:** ![Oystein\_Selbekk](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/oystein_selbekk/32/1677_2.png) [@Oystein\_Selbekk](https://community.appfarm.io/u/Oystein_Selbekk)\
**Post date:** [October 17, 2024, 11:40pm UTC](https://community.appfarm.io/t/nested-iterations-on-objects/1454/3 "2024-10-17T23:40:23Z")

</div>

Hi Kristian and thank you for the response. I made a secondary collection of the same objects, and now it works 🙂  
Øystein
