Weird Custom Property Behavior

I’ve got an issue that I can’t wrap my head around on 8.1.37

I’ve got a custom property on my view that is an object that contains a list of objects:

Object Structure
view.custom.data = {
  "Value1": "",
  "Value2": 0,
  "Value3": 0,
  "ListOfObjects": [
    {
      "item": 2,
      "count": 1,
      "row": 0
    },{
      "item": 13,
      "count": 6,
      "row": 1
    },{
      "item": null,
      "count": 0,
      "row": 2
    }
  ]
}

I’ve got a dropdown view that sits in a table column with view render type. It sends a message to the page when it changes to update the item of the selected object in the list of objects by handing the ‘row’ and ‘value’ as an int or a long (I’ve tried both). I’ve tried a couple variations of the logic:

Message Script On Table

Original:

self.view.custom.object.listOfObjects[payload['row']].update({'item':payload['value']

Alternative 1

(On the premise that maybe the update function directly on the child of the list was problematic)

temp = self.view.custom.object.listOfObjects 
# I've also tried casting parts to a list
temp[payload['row']].update({'item':payload['value']})
self.view.custom.object.listOfObjects = temp

Instead of changing the array, though, I get a new custom property object.listOfObjects[0] (which the designer doesn’t like as a key name of course) with the value {'item':intValue}.

Is there something that I’m doing wrong to update a single key in an object contained in a list?

Ok, I just realized that if I just assign it like self.view.custom.object.listOfObjects[int(payload['row'])]['item'] = payload['value'] it works perfectly fine. Not sure why the update function is weird, even if I cast everything to “normal” python types, but problem fixed I guess?

It's a known issue with the object wrapper on perspective properties.

I normally use a modified version of the sanitize function from this post whenever I'm interacting with a dict or list property in a script:

2 Likes

Oh, ok. I had poked around for several hours trying to find something about it. I didn’t include the term object wrapper since when I find solutions to problems here, they don’t tend to have the right namings, so I usually just describe the end result that’s unwanted. Thank you for attaching those links, though.