# Change Variable Value - Partial update of an array within object

**URL:** <https://community.weweb.io/t/change-variable-value-partial-update-of-an-array-within-object/4332>\
**Category:** Ask us anything\
**Created:** [September 14, 2023, 3:22am UTC](https://community.weweb.io/t/change-variable-value-partial-update-of-an-array-within-object/4332 "2023-09-14T03:22:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpher](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/cpher/32/4898_2.png) [@cpher](https://community.weweb.io/u/cpher)\
**Post date:** [September 14, 2023, 3:22am UTC](https://community.weweb.io/t/change-variable-value-partial-update-of-an-array-within-object/4332/1 "2023-09-14T03:22:57Z")

</div>

Hi there, I’ve hit an issue trying to update an item in an array within an object variable using partial update.

Here is the Object with the element I’m trying to update highlighted:  
And I’ve added the relative path in the formula

 ![Partial-update---Object](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/f/fa504d7a350d87ad91298318fc3618cf882ffbc4.jpeg)

I can see that I’m targeting the correct element, as the result is being read correctly, however when testing, the element is not updating. I feel like I’m making a rookie mistake here. Any advice would be most helpful. 😉

---

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/max/32/4844_2.png) [@Max](https://community.weweb.io/u/Max)\
**Post date:** [September 14, 2023, 5:46am UTC](https://community.weweb.io/t/change-variable-value-partial-update-of-an-array-within-object/4332/2 "2023-09-14T05:46:29Z")

</div>

Hi! I have two thoughts:

- The update is pretty deep in you object structure. Maybe the “Partial Update” has a limit. If so, you can do this via Javascript
- You are using different indices (`item.parent.parent.index`, `item.parent.index` and `item.index`). Are you sure this is correct?

---

<div class="post-metadata">

**Author:** ![cpher](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/cpher/32/4898_2.png) [@cpher](https://community.weweb.io/u/cpher)\
**Post date:** [September 14, 2023, 7:08am UTC](https://community.weweb.io/t/change-variable-value-partial-update-of-an-array-within-object/4332/3 "2023-09-14T07:08:15Z")

</div>

Hey Max, thank you for your feedback,

Based on the object structure i think the indices correspond accordingly:  
item.index = ratings  
item.parent.index = bars  
item.parent.parent.index = data

I can use partial update formula to update items at the first level, but I can’t seem to update items at 2nd or 3rd.

I’ll try the JS route as per your suggestion.

---

<div class="post-metadata">

**Author:** ![cpher](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/cpher/32/4898_2.png) [@cpher](https://community.weweb.io/u/cpher)\
**Post date:** [September 14, 2023, 7:57am UTC](https://community.weweb.io/t/change-variable-value-partial-update-of-an-array-within-object/4332/4 "2023-09-14T07:57:49Z")

</div>

Odd,

There has just been a application maintenance and now the item menu has disappeared!

 ![Screenshot 2023-09-14 at 17.56.53](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/5/53aa87e19b510dc569541a596179272ad27b9c52.png)

I now have no access to the scope of the current item.

---

<div class="post-metadata">

**Author:** ![jaredgibb](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jaredgibb](https://community.weweb.io/u/jaredgibb)\
**Post date:** [September 14, 2023, 10:47am UTC](https://community.weweb.io/t/change-variable-value-partial-update-of-an-array-within-object/4332/5 "2023-09-14T10:47:48Z")

</div>

Are you trying to update a value in a collection item? `area_attribute_result_object` if so, that’s not how you’d do it.

They are read only afaik. You’d need to make an update call to your backend.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [September 14, 2023, 1:33pm UTC](https://community.weweb.io/t/change-variable-value-partial-update-of-an-array-within-object/4332/6 "2023-09-14T13:33:36Z")

</div>

Go to custom javascript and do this

**[area\_attribute\_result\_obj.data][item.parent.parent.index].bars[item.parent.index].ratings[item.index].result = true**

or if you have it within the context, you can directly target the result, you might see it there

**[result] = true**

if you want to do it via path, you gotta do it like a string I think. Now you are changing

**[area\_attribute\_result\_obj]false**

---

<div class="post-metadata">

**Author:** ![cpher](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/cpher/32/4898_2.png) [@cpher](https://community.weweb.io/u/cpher)\
**Post date:** [September 14, 2023, 11:07pm UTC](https://community.weweb.io/t/change-variable-value-partial-update-of-an-array-within-object/4332/7 "2023-09-14T23:07:25Z")

</div>

Thanks Broberto,

Super helpful … using Custom Javascript worked. Using the context item made it super simple too.

context.item.data.result = true

Big thanks 🙂 🤩

---

<div class="post-metadata">

**Author:** ![suebphatt](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/suebphatt/32/10078_2.png) [@suebphatt](https://community.weweb.io/u/suebphatt)\
**Post date:** [July 25, 2024, 8:09am UTC](https://community.weweb.io/t/change-variable-value-partial-update-of-an-array-within-object/4332/8 "2024-07-25T08:09:25Z")

</div>

I know this is old topic. This problem stole my whole afternoon, but I found a solution.  
For anyone who want to stick with no-code way, and don’t want to go custom Javascript.

Since [this hero](https://community.weweb.io/t/partial-update-of-an-array-within-object/3011/3) mentioned that the “path” property of the partial update uses RELATIVE path. I solved that by convert the whole dynamic relative path to a string, then return it 😀.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/5/5022d6303f7042fe1bb872cf5879bc01324133b7.png)
