# Variable updated with Run code does not work

**URL:** <https://community.appfarm.io/t/variable-updated-with-run-code-does-not-work/1200>\
**Category:** Bug reports\
**Tags:** actions\
**Created:** [April 26, 2024, 7:58pm UTC](https://community.appfarm.io/t/variable-updated-with-run-code-does-not-work/1200 "2024-04-26T19:58:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Preben](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/preben/32/545_2.png) [@Preben](https://community.appfarm.io/u/Preben)\
**Post date:** [April 26, 2024, 7:58pm UTC](https://community.appfarm.io/t/variable-updated-with-run-code-does-not-work/1200/1 "2024-04-26T19:58:33Z")

</div>

Hi,

When using a run code component to update a geo location (long, lat) I noticed that condition on data that the run code component has updated is not working correctly.

In the example under I have a condition to be true if one of the fields fetched from the device position has data. The same field is required in the web request running just after the condition.

As you can see the condition is false, but the web request is successful

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/e/ea33bcc8f6b8a658a6a3a2c7a3b8cf2a5267b427.png)

There is also visible data in the devtool. I also noticed the same issue in conditions for visibility groups, but have not reproduced that today  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/8/89194c293ce6df68292d4389811cd8259776d60d.png)

---

<div class="post-metadata">

**Author:** ![ErikAKSkallevold](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/erikakskallevold/32/1378_2.png) [@ErikAKSkallevold](https://community.appfarm.io/u/ErikAKSkallevold)\
**Post date:** [April 28, 2024, 3:33pm UTC](https://community.appfarm.io/t/variable-updated-with-run-code-does-not-work/1200/2 "2024-04-28T15:33:25Z")

</div>

Hello Preben,

How are you updating these values in the `Run code`?

Also, even if it is technically possible to write raw values to data from `Run code` it is not the recommended way of updating properties on an object. Instead I recommend creating an action for updating these values, and the calling that from within the `Run code`.  
We have an example on how to do this in [our docs](https://docs.appfarm.io/library/action-nodes/run-code).

Here is a small example of action with two action params being called from a `Run code`.

 ![bilde](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/c/c54444842761f901de7e446bf746793f211b0d07.png)

![bilde](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/b/b7dd2c891354f054cee88c1bf8c211035bbdb55e.png)

 ![bilde](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/8/8f91ba02f0030f8fa916a590be887a2d3fb61e47.png)

 ![bilde](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/c/ca628c9843136027855a3106a01ff91b876432a9.png)

Hope this helps.  
//Erik

---

<div class="post-metadata">

**Author:** ![Preben](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/preben/32/545_2.png) [@Preben](https://community.appfarm.io/u/Preben)\
**Post date:** [April 28, 2024, 6:54pm UTC](https://community.appfarm.io/t/variable-updated-with-run-code-does-not-work/1200/3 "2024-04-28T18:54:24Z")

</div>

That was a good tip, I was not aware of this possiblity in run code. Thanks!
