# Error: Unable to find object in context - Iterator has probably been changed

**URL:** <https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535>\
**Category:** Bug reports\
**Created:** [November 27, 2024, 10:11am UTC](https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535 "2024-11-27T10:11:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anders1](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@anders1](https://community.appfarm.io/u/anders1)\
**Post date:** [November 27, 2024, 10:11am UTC](https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535/1 "2024-11-27T10:11:25Z")

</div>

I am working in a service where I have two runtime data sources, I will refer to them as X (cardinality-many) and Y (cardinality-one) and they are of the same object class.

 ![Data source X](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/9/9d75130c0e0d7f0816b437be9e253e73a2a23a6c.png)  
 ![Data source Y](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/8/8481b7b93dfbb4e109a48c5eb1978a3ac19a658c.png)

I have a for loop that iterates over a data source and in each iteration, I would like to create a new object in X with properties that do not depend on the current data source that I am iterating on. However, I get the error message: `Error: Unable to find object in context - Iterator has probably been changed`.

Now that is strange, because that literally happens in the first iteration, and I haven’t modified the iterating data source at all.

Nevertheless, I tried a workaround solution to create an object in Y first then read it to X, but the same error message occurs again.

At this point, I’m just confused. To investigate further, I tried to create an object in Y **OUTSIDE** the loop and filled the properties with some hardcoded values that do not depend on any other data source - and the exact same error message appears. Note that I’m not even depending on any object in context, I’m just creating a completely new object.

 ![Error appearing at create object action node](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/9/90898f3f8a496a354efd8d9e3569b7df28d01edd.png)

As you can see from the attached image, this is the flow that I’m using now, the disabled create object was to create an object in Y and the one with the error is creating an object in X. Both result in the same error.

 ![Error in log](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/9/995ffb8ecd67dc37076342882a9cd052296e56f3.png)

I checked the permissions for the object class and I already enabled `Create, Read, Update, Delete`.

Does this happen to be a bug?

---

<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:** [November 27, 2024, 10:31am UTC](https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535/2 "2024-11-27T10:31:51Z")

</div>

Hi!

First off: Are you iterating the same data source `Order line (runtime, many)` twice (I see 2 “For each” loops)? Og just in the outer loop? And, are you setting selection on that same data source?

You cannot iterate the same datasource twice (since it will have 2 contexts inside the inner loop - not a feature we have), and if so I guess you might get errors like this. Also note when combining iterations with selection, you must be aware that [object in context supercede the selected object](https://docs.appfarm.io/reference/platform-concepts/objects).

This is not a direct answer, but might help to pinpoint the issue!

---

<div class="post-metadata">

**Author:** ![anders1](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@anders1](https://community.appfarm.io/u/anders1)\
**Post date:** [November 27, 2024, 11:26am UTC](https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535/3 "2024-11-27T11:26:26Z")

</div>

Nope, I’m not iterating on the `Order line (runtime, many)` data source; the for loops are iterating on separate data sources that are not of the object class `order line`. I’m just creating an object which is independent of any other data sources. In theory it should work.

---

<div class="post-metadata">

**Author:** ![anders1](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@anders1](https://community.appfarm.io/u/anders1)\
**Post date:** [November 27, 2024, 11:45am UTC](https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535/4 "2024-11-27T11:45:06Z")

</div>

@kristian Here are the screenshots of what I tried out where I tried creating an object in `Order line (runtime, one)`.

 ![Action set up](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/9/9ef221e5735a95cd526b1732115ed5f7d5a1e63f.png)

 ![Service flow](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/a/a834c3efc39ae06cfe9695df36f872d545a94a7e.png)

 ![Screenshot 2024-11-27 at 12.43.08](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/2/2f0a9324427cf3c2be3471cbc773b5da34a6b0b3.png)

As you can see, just creating the object at the start of the action already causes the same error

---

<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:** [November 27, 2024, 12:19pm UTC](https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535/5 "2024-11-27T12:19:52Z")

</div>

Ok, thanks. In the red error box, can you screenshot the “Show details” as well as providing a screenshot of the Create Object setup failing? Might DM if easier.

---

<div class="post-metadata">

**Author:** ![anders1](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@anders1](https://community.appfarm.io/u/anders1)\
**Post date:** [November 27, 2024, 12:27pm UTC](https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535/6 "2024-11-27T12:27:27Z")

</div>

@kristian sent you a DM, thanks!

---

<div class="post-metadata">

**Author:** ![sigveskavik](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/sigveskavik/32/1488_2.png) [@sigveskavik](https://community.appfarm.io/u/sigveskavik)\
**Post date:** [February 4, 2025, 8:29am UTC](https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535/7 "2025-02-04T08:29:46Z")

</div>

Hey Kristian!

Did you find a solution for this?

---

<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:** [February 4, 2025, 8:59am UTC](https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535/8 "2025-02-04T08:59:37Z")

</div>

Hi,

No, we did not conclude on the reason behind. But re-creating the data source solved it, which supports the hypothesis of some local issue related to the metadata of that specific datasource. If we find a similar case again, we might try to pinpoint it if we can get a copy of the app, and an isolated case (e.g. a button triggering the action with this error), and access to the solution.

---

<div class="post-metadata">

**Author:** ![sigveskavik](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/sigveskavik/32/1488_2.png) [@sigveskavik](https://community.appfarm.io/u/sigveskavik)\
**Post date:** [February 4, 2025, 10:58am UTC](https://community.appfarm.io/t/error-unable-to-find-object-in-context-iterator-has-probably-been-changed/1535/9 "2025-02-04T10:58:18Z")

</div>

Hi!

Ok, thanks! I just tried recreating the datasource which did not fix the issue. Creating a new service however fixed it.
