Struggling with Set Property of Object

Hi Thunkers,

I’m struggling with setting the property of an object (JSON) in my app. I have a bunch of text entry boxes which display default values, parsed from a variable which contains a JSON object. When the user edits a text box, I want to use a set property of object block to push the textbox value into the JSON object. I’m currently using the when… unfocus block to perform the update so that when the user clicks away from the textbox it should push the new value to the JSON object. Buuuut, every time I tried this it bounces back to the original value.

I’ve tried with and without a JSON object block for the ‘of object’ bit - neither works
Thunk1
Thunk2

The function ‘populatefields’ is what bounces the value back but it’s just stuffing the textbox with values from the JSON again. That JSON should, by this point, contain the new value.

What stupid thing am I doing wrong?

1 Like

According to @muneer, you can’t set the property of an object using a get object from JSON block.

See this: How to change the property of a nested object - #17 by muneer

1 Like

Just a side note that stored variables are slow. Really slow compared to app variables. I would recommend that when you have a function where you access the same stored variable repeatedly, you instead set an app variable to the stored variable’s value and then use the app variable throughout your code. It’s best to only use a stored variable block when you are changing the value of that variable.

1 Like

Thanks @tatiang that’s exactly it! I figured it’d be something to do with the JSON conversion but couldn’t work out what I was doing wrong.

RE: stored variables, I agree. I was in the process of cleaning that up and moving to app variable after your last comment but got stuck here and then got distracted :joy:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.