# Modifying Document Tag Values in Script

**URL:** <https://forum.inductiveautomation.com/t/modifying-document-tag-values-in-script/76304>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 13, 2023, 7:43am UTC](https://forum.inductiveautomation.com/t/modifying-document-tag-values-in-script/76304 "2023-07-13T07:43:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [July 13, 2023, 7:43am UTC](https://forum.inductiveautomation.com/t/modifying-document-tag-values-in-script/76304/1 "2023-07-13T07:43:08Z")

</div>

I figure it's about time I asked this question.

What is the most efficient way to modify a document tag's value?

The value itself is read in as a [PyDocumentObjectAdapter](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.1/com/inductiveautomation/ignition/common/script/adapters/PyDocumentObjectAdapter.html) object which doesn't appear to have any methods to manipulate the object data; no add, remove, or set methods.

What I _have_ been using seems a bit over zealous, but at least it works. I use a script that's essentially similar to this [Comparing Perspective Object - Never the same? - #2 by PGriffith](https://forum.inductiveautomation.com/t/comparing-perspective-object-never-the-same/53085/2) which recursively converts all of the objects and their items into Py dicts and lists. For large documents though, this obviously isn't that efficient. You then also have to convert this back into JSON when you write it back to the tag. I've found instances where this doesn't work due to "maximum recursion depth reached" (despite only being 3-4 levels deep).

Is there a more direct way to do this and operate on the ObjectAdapter itself?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 13, 2023, 11:47am UTC](https://forum.inductiveautomation.com/t/modifying-document-tag-values-in-script/76304/2 "2023-07-13T11:47:17Z")

</div>

I haven't tried on complex structures, but did you try `doctag.toDict()` ?  
Or `dict(doctag)` for that matter.
