# Binding Property to Document Memory Tag

**URL:** <https://forum.inductiveautomation.com/t/binding-property-to-document-memory-tag/36613>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [July 11, 2020, 10:50pm UTC](https://forum.inductiveautomation.com/t/binding-property-to-document-memory-tag/36613 "2020-07-11T22:50:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rberghammer](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rberghammer/32/7150_2.png) [@rberghammer](https://forum.inductiveautomation.com/u/rberghammer)\
**Post date:** [July 11, 2020, 10:50pm UTC](https://forum.inductiveautomation.com/t/binding-property-to-document-memory-tag/36613/1 "2020-07-11T22:50:56Z")

</div>

I would like to store data in a document tag and allow users to view & modify the data using a perspective table. The table is bound to a custom property:  
 ![Custom Property](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/6/56b73f55a573c645277cc212315007f4df0b7a69.png)

So far, I can get the table to display the data, but I can’t figure out how to write changes back to the tag. If I set the binding to “Bi-Directional”, values immediately revert if I try to change them.

I have also tried disabling the “Bi-Directional” option and creating a “Save” button to write back with a script. This seems the most promising, but I’m still having trouble.

This code works if I create a dictionary and write it to the document tag.

```auto
value = system.util.jsonEncode(str(dict))
system.tag.writeBlocking([path],[value])

```

But if I try to encode the bound property like this:

```auto
parValue = self.view.custom.object
value = system.util.jsonEncode(str(parValue))
system.tag.writeBlocking([path],[value])

```

My memory tag gets a bad value:

 ![Document Tag](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/116e1a3e7aba839726b84f2a9069d14a3d6bc986.png)

Anyone have any ideas?

---

<div class="post-metadata">

**Author:** ![KGarner](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgarner/32/15999_2.png) [@KGarner](https://forum.inductiveautomation.com/u/KGarner)\
**Post date:** [July 12, 2020, 3:32am UTC](https://forum.inductiveautomation.com/t/binding-property-to-document-memory-tag/36613/2 "2020-07-12T03:32:10Z")

</div>

We’ve not had luck with bidirectional bindings on objects primarily because the elements within objects do not trigger an update. If you want to go with a bidirectional binding, you might have better luck rewriting the modified object back to the property e.g.

```auto
copiedObject = dict(self.view.custom.object)
copiedObject[“key”] = value

self.view.custom.object = system.util.jsonEncode(copiedObject)

```

Disclaimer: I have not tested this.

That said, I think the Save button is the better route. In that case, you should be able to type cast the JavaScript object into a dictionary before encoding to JSON.

```auto
parValue = self.view.custom.object
value = system.util.jsonEncode(dict(parValue))
system.tag.writeBlocking([path],[value])

```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![rberghammer](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rberghammer/32/7150_2.png) [@rberghammer](https://forum.inductiveautomation.com/u/rberghammer)\
**Post date:** [July 16, 2020, 2:11am UTC](https://forum.inductiveautomation.com/t/binding-property-to-document-memory-tag/36613/3 "2020-07-16T02:11:03Z")

</div>

Thanks @KGarner. I had a chance to work on this again tonight, but I’m still having issues.

When I try to use `system.util.jsonEncode(dict(parValue))`

I get an error:  
`RuntimeError: maximum recursion depth exceeded (Java StackOverflowError)`

I’m not sure if this is related to the data in my tag or a problem with my code.

I was able to get some other code to work where I load the document tag, modify the value, and write it back. But I can’t figure out how to do the same thing using data from a view parameter.

---

<div class="post-metadata">

**Author:** ![rberghammer](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rberghammer/32/7150_2.png) [@rberghammer](https://forum.inductiveautomation.com/u/rberghammer)\
**Post date:** [July 24, 2020, 11:41pm UTC](https://forum.inductiveautomation.com/t/binding-property-to-document-memory-tag/36613/4 "2020-07-24T23:41:19Z")

</div>

Just talked to support about the error in my last comment. I’ll try to explain this, but anyone with more knowledge is welcome to jump in if I slaughter this explanation.

Using `system.util.jsonEncode` with simple view parameters work fine, but if the parameter contains an array, it doesn’t work. This is because view parameters are not primitive types like ‘list’ or ‘dictionary’, but instead use a wrapper type and need to be converted to work with some functions.

Here is the code required to write a view parameter named ‘object’ to a document memory tag:

```auto
from com.inductiveautomation.ignition.common import TypeUtilities
parValue = unicode(TypeUtilities.pyToGson(self.view.custom.object))
system.tag.write(path, parValue)

```

Thanks to Mitchell at Inductive support for helping me find the solution.

---

<div class="post-metadata">

**Author:** ![Chris\_Bingham](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Chris\_Bingham](https://forum.inductiveautomation.com/u/Chris_Bingham)\
**Post date:** [April 8, 2026, 7:38pm UTC](https://forum.inductiveautomation.com/t/binding-property-to-document-memory-tag/36613/5 "2026-04-08T19:38:05Z")

</div>

As of 8.1, I believe `TypeUtilities` also has a `.toDocument()` method, which appears to return the same type as the document tag, making it easier to work with:

```python
from com.inductiveautomation.ignition.common import TypeUtilities

documentTag = system.tag.readBlocking(tagPaths="[default]path/to/documentTag")[0].value
print type(documentTag)
# <type 'com.inductiveautomation.ignition.common.script.adapters.PyDocumentObjectAdapter'>

someProperty = TypeUtilities.toDocument(self.view.custom.someProperty)
print type(someProperty)
# <type 'com.inductiveautomation.ignition.common.script.adapters.PyDocumentObjectAdapter'>

```

Whereas:

```python
print type(TypeUtilities.pyToGson(self.view.custom.someProperty))
# <type 'com.inductiveautomation.ignition.common.script.adapters.PyJsonObjectAdapter'>

```
