# \[IGN-1660\] ObjectWrapper modification

**URL:** <https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692>\
**Category:** Ignition Early Access\
**Created:** [November 5, 2019, 5:39pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692 "2019-11-05T17:39:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea.morando](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrea.morando/32/8039_2.png) [@andrea.morando](https://forum.inductiveautomation.com/u/andrea.morando)\
**Post date:** [November 5, 2019, 5:39pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/1 "2019-11-05T17:39:55Z")

</div>

Dears,  
I am currently using the **8.0.5** release.  
After the upgrade from the 8.0.4, I noticed a change in the manipulation of an ObjectWrapper instance.  
For example:  
the code below explains what I found: the param parameter is an ObjectWrapper

```
# Configure additional properties
param.Username = userName
param.Timestamp = fer.util.date.dateToSqlString(fer.util.date.getTimestampUtc())

```

I try to set the Username and Timestamp properties, but they did not change.  
The above code run inside a library in Project Library.

Any idea of this strange behavior?  
Thank you.

---

<div class="post-metadata">

**Author:** ![andrea.morando](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrea.morando/32/8039_2.png) [@andrea.morando](https://forum.inductiveautomation.com/u/andrea.morando)\
**Post date:** [November 6, 2019, 11:40am UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/2 "2019-11-06T11:40:43Z")

</div>

I did another test and the result is still unexpected.  
I created a simple function, that assigns a property value to an object:

```auto
> def fnc(obj, key, value):
> system.perspective.print('key %s' % key)
> system.perspective.print('value %s' % value)
> system.perspective.print('id %s' % id(obj))
> 	
> #setattr(obj, key, value)
> execStr = 'obj.%s = "%s"' % (key, value)
> exec(execStr)
> 	
> system.perspective.print('obj %s' % obj)
> system.perspective.print('id %s' % id(obj))
> 	
> return obj

```

The function is called in a button ActionPerformed action, by:

```auto
	self.view.custom.tree = fer.provaLib.fnc(obj=self.view.custom.tree
										, key=self.getSibling("TextField").props.text
										, value=self.getSibling("TextField_0").props.text)

```

The result is again an object with the same structure, without the expected new property-value pair.

How can I solve this issue?  
Please consider I developed many libraries with that logic and they have worked, before the 8.0.5 upgrade.

Let me know, thank you.  
Andrea

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 6, 2019, 12:46pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/3 "2019-11-06T12:46:22Z")

</div>

@paul-griffith

Probably related to the same changes causing this: [[BUG] tolist() broken in 8.0.5](http://forum.inductiveautomation.com/t/bug-tolist-broken-in-8-0-5/29454)

---

<div class="post-metadata">

**Author:** ![andrea.morando](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrea.morando/32/8039_2.png) [@andrea.morando](https://forum.inductiveautomation.com/u/andrea.morando)\
**Post date:** [November 6, 2019, 12:55pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/4 "2019-11-06T12:55:21Z")

</div>

Do you need further information to fix it?  
Let me know.

---

<div class="post-metadata">

**Author:** ![andrea.morando](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrea.morando/32/8039_2.png) [@andrea.morando](https://forum.inductiveautomation.com/u/andrea.morando)\
**Post date:** [November 6, 2019, 1:04pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/5 "2019-11-06T13:04:32Z")

</div>

On the ActionPerformed of the same button, the direct assignment of a new property, as  
`self.view.custom.tree.test = 'test'`, works fine.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 6, 2019, 4:23pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/6 "2019-11-06T16:23:46Z")

</div>

There’s something a bit weird here, definitely. We’ve got our defect analysts working on isolating the issue - it’s fairly easy to reproduce.

---

<div class="post-metadata">

**Author:** ![osolorzano](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/osolorzano/32/6432_2.png) [@osolorzano](https://forum.inductiveautomation.com/u/osolorzano)\
**Post date:** [November 6, 2019, 4:31pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/7 "2019-11-06T16:31:00Z")

</div>

With the way that the function is called, it should work if you change:

```auto
self.view.custom.tree = fer.provaLib.fnc(obj=self.view.custom.tree
										, key=self.getSibling("TextField").props.text
										, value=self.getSibling("TextField_0").props.text)

```

to just:

```auto
fer.provaLib.fnc(obj=self.view.custom.tree
					, key=self.getSibling("TextField").props.text
					, value=self.getSibling("TextField_0").props.text)

```

Since the fnc() function is directly editing the object passed in. While this shouldn’t be an issue and _is_ a bug that will be fixed, the workaround is to just not re-assign the object to be equal to itself.

---

<div class="post-metadata">

**Author:** ![andrea.morando](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrea.morando/32/8039_2.png) [@andrea.morando](https://forum.inductiveautomation.com/u/andrea.morando)\
**Post date:** [November 6, 2019, 5:15pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/8 "2019-11-06T17:15:10Z")

</div>

Thank you all.  
Let me know (as soon as possible 😀) when the bug will be fixed.  
Unfortunately this gateway is in production and I need to understand which workaround to take.

Bye,  
Andrea

---

<div class="post-metadata">

**Author:** ![andrea.morando](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrea.morando/32/8039_2.png) [@andrea.morando](https://forum.inductiveautomation.com/u/andrea.morando)\
**Post date:** [November 7, 2019, 2:53pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/9 "2019-11-07T14:53:04Z")

</div>

Just to inform you that, in the example above, also the method `obj.update({key: value})` and the syntax `obj[key] = value` do not modify the object obj.

---

<div class="post-metadata">

**Author:** ![andrea.morando](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrea.morando/32/8039_2.png) [@andrea.morando](https://forum.inductiveautomation.com/u/andrea.morando)\
**Post date:** [November 7, 2019, 3:06pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/10 "2019-11-07T15:06:08Z")

</div>

Any workaround to alternatively modify the object?

---

<div class="post-metadata">

**Author:** ![osolorzano](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/osolorzano/32/6432_2.png) [@osolorzano](https://forum.inductiveautomation.com/u/osolorzano)\
**Post date:** [November 7, 2019, 4:32pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/11 "2019-11-07T16:32:47Z")

</div>

All three of the methods there should have worked in 8.0.5 and shouldn’t need a workaround. At this point you’d probably have better luck contacting support so they can take a look and see if there’s something else that is missing from the script.

---

<div class="post-metadata">

**Author:** ![andrea.morando](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrea.morando/32/8039_2.png) [@andrea.morando](https://forum.inductiveautomation.com/u/andrea.morando)\
**Post date:** [November 8, 2019, 2:56pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/12 "2019-11-08T14:56:05Z")

</div>

Solved from my side: I created a custom wrapper class.  
I am looking forward to seeing your fixes.

---

<div class="post-metadata">

**Author:** ![andrea.morando](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrea.morando/32/8039_2.png) [@andrea.morando](https://forum.inductiveautomation.com/u/andrea.morando)\
**Post date:** [December 18, 2019, 10:06am UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/13 "2019-12-18T10:06:22Z")

</div>

Dears,

Any news about this issue? I notice the property assignment of an ObjectWrapper does not work (from 8.0.5 release and above) in the **gateway** scope (instead it works on client side).

Thank you.  
Andrea

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 18, 2019, 4:20pm UTC](https://forum.inductiveautomation.com/t/ign-1660-objectwrapper-modification/29692/14 "2019-12-18T16:20:43Z")

</div>

That doesn’t make any sense - there is no “client” side in Perspective (your scripts are still running on the gateway in a Perspective session) - can you define what you mean by client and gateway?

Also, we’ve identified the root of the problem, but don’t have an ETA on a fix. Basically, mutating the object/array wrapper objects correctly passes those mutations back to the root property tree - but does _not_ update the mutable object you’re actually currently accessing. That’s why Oscar’s workaround above worked - if you don’t reassign the object directly back to the tree, then your value changes go through correctly.

Making the wrapper objects less co-dependent is probably the fix, but it’s not yet actively being worked on.
