# Vision - User Defined Object?

**URL:** <https://forum.inductiveautomation.com/t/vision-user-defined-object/83386>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [December 20, 2023, 6:19pm UTC](https://forum.inductiveautomation.com/t/vision-user-defined-object/83386 "2023-12-20T18:19:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tyler.robertson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tyler.robertson/32/18299_2.png) [@tyler.robertson](https://forum.inductiveautomation.com/u/tyler.robertson)\
**Post date:** [December 20, 2023, 6:19pm UTC](https://forum.inductiveautomation.com/t/vision-user-defined-object/83386/1 "2023-12-20T18:19:03Z")

</div>

Hi all - is there something in vision like an Object data type for Custom Properties,

I have an application where I'm using a client script to open a socket for TCP communication with a device (RFID reader) and everything works great for reading while the vision gui is active so long as a use system.util.invokeAsynchronous. However, then the socket exists on some other thread, and isn't stored anywhere that I can access?

ie: on my 'rfid\_connect' event on startup, or on a button I have:  
returned\_thread = system.util.invokeAsynchronous(RFID.RFID\_CLIENT,[state\_path,path,enb\_path,connected\_path,ip,port])

But I can't seem to find a way to store that returned thread in something I can then access in another event or script?

Problem then is if I need to send a command to that device, even though there's an active socket I have to open a second second, send a command, and close.

Thank you!

---

<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 20, 2023, 6:23pm UTC](https://forum.inductiveautomation.com/t/vision-user-defined-object/83386/2 "2023-12-20T18:23:58Z")

</div>

`system.util.getGlobals`/`system.util.globals` exposes a persistent string-keyed dictionary capable of holding any arbitrary type. It lasts as long as the local JVM is open (so the Vision client, Designer, or Gateway instance).

Be careful not to put any custom Jython classes into it, or you're prone to memory leaks, but that's less of a concern in client scoped executions.

---

<div class="post-metadata">

**Author:** ![tyler.robertson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tyler.robertson/32/18299_2.png) [@tyler.robertson](https://forum.inductiveautomation.com/u/tyler.robertson)\
**Post date:** [December 20, 2023, 6:36pm UTC](https://forum.inductiveautomation.com/t/vision-user-defined-object/83386/3 "2023-12-20T18:36:47Z")

</div>

Ah!!! Thank you! that's wonderful.

no 'setGlobals' ?? 😛

`# Write value 'hello' to global variable 'foo'.`

`system.util.getGlobals()[` `'foo'` `] ` `=` `'hello'`

---

<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 20, 2023, 6:39pm UTC](https://forum.inductiveautomation.com/t/vision-user-defined-object/83386/4 "2023-12-20T18:39:50Z")

</div>

`system.util.getGlobals` returns the singleton instance; you can also use Jython's property access shortcut syntax: `system.util.globals`.

Since it's just a regular Python/Jython dictionary, you can (and should) use Python methods like `setdefault` for thread-safe access to a default value in the dictionary, depending on what you're ultimately stashing in it, ex.  
`system.util.globals.setdefault("someKey", "someDefault")`

---

<div class="post-metadata">

**Author:** ![tyler.robertson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tyler.robertson/32/18299_2.png) [@tyler.robertson](https://forum.inductiveautomation.com/u/tyler.robertson)\
**Post date:** [December 20, 2023, 8:17pm UTC](https://forum.inductiveautomation.com/t/vision-user-defined-object/83386/5 "2023-12-20T20:17:57Z")

</div>

I have achieved supreme victory - thank you!
