# Access Class instance from different perspective script environments

**URL:** <https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439>\
**Category:** Ignition\
**Created:** [April 9, 2021, 3:45pm UTC](https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439 "2021-04-09T15:45:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [April 9, 2021, 3:45pm UTC](https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439/1 "2021-04-09T15:45:15Z")

</div>

If I create an instance of a class in a view like this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/2/22c276abdcef2b9b106a438459b78ad81e00faeb.png)

That class is given a place in memory i.e. `< __builtin__.test instance at 0x8>`

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b60df49be9a0cbfa7ad9299f1610bdf41ac04ca5.png)

If I know that memory address, is there any way that I can recall the instance of `test` on the second button in this page?

I don’t know if Java would allow me to do this or Python, but it would be convenient for a few use cases.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 9, 2021, 3:52pm UTC](https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439/2 "2021-04-09T15:52:33Z")

</div>

Noooooope

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [April 9, 2021, 3:54pm UTC](https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439/3 "2021-04-09T15:54:31Z")

</div>

I guess another way to ask this question based off the problem,

Is there any way for me to instantiate the class in button one, and reference it in button two.

I know that I could make it serializable, store it as an object in a custom property, and then de-serialize it in the second buttons script. However sometimes you just can’t make thing serializable, so I am trying to see if I can get around that.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 9, 2021, 3:55pm UTC](https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439/4 "2021-04-09T15:55:16Z")

</div>

`system.util.getGlobals` maybe?

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [April 9, 2021, 3:58pm UTC](https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439/5 "2021-04-09T15:58:49Z")

</div>

> [@Kevin.Herron](#):
>
> `system.util.getGlobals`

Is this just a Map in the jvm? I see that they persist across gateway lifetime which leads me to believe the instance still needs to be serializable, is this correct?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 9, 2021, 4:00pm UTC](https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439/6 "2021-04-09T16:00:59Z")

</div>

> [@kgamble](#):
>
> I see that they persist across gateway lifetime which leads me to believe the instance still needs to be serializable, is this correct?

I think what that line means is that your globals map won't be emptied every time your scripting restarts from e.g. saving a project. Not that it will be persisted and accessible again if your gateway restarts. The contents of the map do not need to be serializable.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [April 9, 2021, 4:02pm UTC](https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439/7 "2021-04-09T16:02:12Z")

</div>

Sweet, thanks!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 9, 2021, 4:02pm UTC](https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439/8 "2021-04-09T16:02:53Z")

</div>

If that’s not actually the case then I have no idea why the documentation team wrote that.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [April 9, 2021, 4:03pm UTC](https://forum.inductiveautomation.com/t/access-class-instance-from-different-perspective-script-environments/45439/9 "2021-04-09T16:03:50Z")

</div>

Just tested it with a publish and my example still works!
