# Datasets arriving to Component Message Handlers as 'PropertyTreeScriptWrapper.ArrayWrapper.html'

**URL:** <https://forum.inductiveautomation.com/t/datasets-arriving-to-component-message-handlers-as-propertytreescriptwrapper-arraywrapper-html/97047>\
**Category:** Ignition\
**Tags:** ignition81, scripting, perspective\
**Created:** [October 9, 2024, 7:43pm UTC](https://forum.inductiveautomation.com/t/datasets-arriving-to-component-message-handlers-as-propertytreescriptwrapper-arraywrapper-html/97047 "2024-10-09T19:43:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Martin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew_martin/32/33340_2.png) [@Andrew\_Martin](https://forum.inductiveautomation.com/u/Andrew_Martin)\
**Post date:** [October 9, 2024, 7:43pm UTC](https://forum.inductiveautomation.com/t/datasets-arriving-to-component-message-handlers-as-propertytreescriptwrapper-arraywrapper-html/97047/1 "2024-10-09T19:43:16Z")

</div>

I've been struggling for a few days with a problem that started when I tried to convert a dataset to a pydataset.

I have a dataset that is generated by a named query on a custom component.  
On this component, I have no trouble calling [toPyDataset](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-dataset/system-dataset-toPyDataSet)  
On a separate custom property, I grab the type of this dataset, and print it out.

I then pass the dataset to a secondary component as a parameter. (My primary is a Map, the secondary is a view that's tied in with the customControl ~'embedded view'~ prop of the Map, if you're curious)

this secondary view gets this lovely data passed as a parameter.  
On a separate custom property on the view, I grab the type of this dataset parameter, and print it out.

Lastly, I have a message handler which reacts to a different set of changing data. My ultimate goal is to be able to read data out of the secondary view's dataset parameter and print out data.  
Inside of the message handler script I grab the type of this dataset from the secondary view, and print it out.

And here's the fantastic result of all three of these print statements, once I navigate to this page!

```python
Primary : <type 'com.inductiveautomation.ignition.common.JsonDataset'>
Primary : <type 'com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataset'>
Secondary: <type 'com.inductiveautomation.ignition.common.JsonDataset'>
Secondary: <type 'com.inductiveautomation.perspective.gateway.script.JsonifiableArrayList'>
in Message Handler: <type 'com.inductiveautomation.perspective.gateway.script.PropertyTreeScriptWrapper$ArrayWrapper'>

```

Isn't that grand! three different dataset types. BasicStreamingDataset, JsonifiableArrayList, and. PropertyTreeScriptWrapper$ArrayWrapper'.  
the first two i've been able to manipulate. the last one? completely unsuccessful.

Tried looking at the doc for [ArrayWrapper](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.0/com/inductiveautomation/perspective/gateway/script/PropertyTreeScriptWrapper.ArrayWrapper.html) and i'm... i'm lost. should I even be able to iterate over it?

getPyDataset breaks without returning anything. ditto with jsonDecode, .items(). I really don't wanna have to toString it and do some funky jsonEncode stuff unless I have to.  
Any direction or support would help. the existing threads on [reading an object wrapper](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446) seemed to be on the right track but didn't include any code I could use and used a clunky method. like victordcq said, 'You should not have to en/decode it to json'.  
code for the curious.

```python
def onMessageRecieved(self, payload):
  NFSM = self.view.params.Nav_Filter_Sites_Map
  system.perspective.print('in Message Handler: ' + str(type(NFSM)))

```

with gratitude,  
-AM

---

<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:** [October 9, 2024, 7:58pm UTC](https://forum.inductiveautomation.com/t/datasets-arriving-to-component-message-handlers-as-propertytreescriptwrapper-arraywrapper-html/97047/2 "2024-10-09T19:58:06Z")

</div>

Can you break down the exact problem you have and what you're trying to solve?

```python
Primary : <type 'com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataset'>
Secondary: <type 'com.inductiveautomation.ignition.common.JsonDataset'>

```

Only these first two types are actually Dataset types.

```python
Secondary: <type 'com.inductiveautomation.perspective.gateway.script.JsonifiableArrayList'>
in Message Handler: <type 'com.inductiveautomation.perspective.gateway.script.PropertyTreeScriptWrapper$ArrayWrapper'>

```

These two types are both, essentially, _imitations_ of a Python **list** , just like `PyDataset` is. That list _may_ contain "row-like" objects, or it may not - the type of the outer list won't tell you.

There's more and less good rational explanations for why all these different types are being surfaced to you, but the generally better guiding principle is to just not care, and treat things as what they pretend to be.

---

<div class="post-metadata">

**Author:** ![Andrew\_Martin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew_martin/32/33340_2.png) [@Andrew\_Martin](https://forum.inductiveautomation.com/u/Andrew_Martin)\
**Post date:** [October 9, 2024, 8:08pm UTC](https://forum.inductiveautomation.com/t/datasets-arriving-to-component-message-handlers-as-propertytreescriptwrapper-arraywrapper-html/97047/3 "2024-10-09T20:08:52Z")

</div>

Ok! hey thank you for giving me hope! so the goal I had was to be able to iterate over the PropertyTreeScriptWrapper$ArrayWrapper' that the message handler picks up from `self.view.params.Nav_Filter_Sites_Map` there's some data inside of that dataset that i'd like to use.  
since toPyDataset doesn't work, my guess is because there's some sort of wrapper around the data in that object? But yeah, essentially how do I get to those delicious morsels of dataset data.  
the drawback I kept running into with testing this too was not getting any console data from system.perspective.print after attempting a 'toPyDataset', I assume my scripting just failed in a less-visible sort of way

---

<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:** [October 9, 2024, 8:12pm UTC](https://forum.inductiveautomation.com/t/datasets-arriving-to-component-message-handlers-as-propertytreescriptwrapper-arraywrapper-html/97047/4 "2024-10-09T20:12:57Z")

</div>

When dealing with an ArrayWrapper, just treat it as a regular list, e.g:

```python
for i, site in enumerate(self.view.params.Nav_Filter_Sites_Map):
	system.perspective.print("Index %s" % i)
	system.perspective.print(str(type(site))
	system.perspective.print(repr(site))

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 9, 2024, 8:15pm UTC](https://forum.inductiveautomation.com/t/datasets-arriving-to-component-message-handlers-as-propertytreescriptwrapper-arraywrapper-html/97047/5 "2024-10-09T20:15:31Z")

</div>

Probably something like:

```python
for row in self.view.params.Nav_Filter_Sites_Map:
    print row['ColumnName']

```

You'll find that your ArrayWrapper is an Array of ObjectWrappers, which looks almost exactly like a List of Dictionaries.

Of course, you could set your Named Query Binding's return format to `dataset` and pass around an actual Dataset object too.

> [@Andrew\_Martin](#):
>
> not getting any console data from system.perspective.print after attempting a 'toPyDataset', I assume my scripting just failed in a less-visible sort of way

Yes, it was never reaching the print call.

---

<div class="post-metadata">

**Author:** ![Andrew\_Martin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew_martin/32/33340_2.png) [@Andrew\_Martin](https://forum.inductiveautomation.com/u/Andrew_Martin)\
**Post date:** [October 9, 2024, 8:28pm UTC](https://forum.inductiveautomation.com/t/datasets-arriving-to-component-message-handlers-as-propertytreescriptwrapper-arraywrapper-html/97047/6 "2024-10-09T20:28:16Z")

</div>

Thank you thoroughly! Both of your solutions provide that sweet, delectable, data access that I needed!

```python
#PGriffith
	for i, site in enumerate(self.view.params.Nav_Filter_Sites_Map):
		system.perspective.print("Index %s" % i)
		system.perspective.print(str(type(site)))
		system.perspective.print(repr(site))
#lrose		
	for row in self.view.params.Nav_Filter_Sites_Map:
		system.perspective.print( row['Latitude'])

```

I'll be on my merry way then.

@paul-griffith, thanks for helping get me un-stuck! I'm going to go learn about 'repr' now, it looks handy!

And thank you too @lrose! Great knowing another Illinois graduate is on here. I-L-L !

-AM

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 9, 2024, 9:41pm UTC](https://forum.inductiveautomation.com/t/datasets-arriving-to-component-message-handlers-as-propertytreescriptwrapper-arraywrapper-html/97047/7 "2024-10-09T21:41:34Z")

</div>

> [@Andrew\_Martin](#):
>
> Great knowing another Illinois graduate is on here. I-L-L !

Well, I didn’t actually graduate from there, instead graduated from SIUE, but I grew up in IL and have been a life long fan, so I-N-I !

---

<div class="post-metadata">

**Author:** ![Andrew\_Martin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew_martin/32/33340_2.png) [@Andrew\_Martin](https://forum.inductiveautomation.com/u/Andrew_Martin)\
**Post date:** [November 2, 2024, 5:24pm UTC](https://forum.inductiveautomation.com/t/datasets-arriving-to-component-message-handlers-as-propertytreescriptwrapper-arraywrapper-html/97047/8 "2024-11-02T17:24:39Z")

</div>

The work continues!  
This was solved, but there are lots of wrappers in use across perspective if you're reading this thread and want more info, there's a fantastic couple of script tools [here](https://forum.inductiveautomation.com/t/bug-system-util-sendmessage-fails-with-remoteservers-when-payload-is-not-a-dict/55040/8) that were cooked up by some talented members of the community.  
Good luck; have fun!
