# Convert Object Reference in Perspective Parameter to Actual Object

**URL:** <https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [May 22, 2024, 10:21pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766 "2024-05-22T22:21:51Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbachman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rbachman/32/43718_2.png) [@rbachman](https://forum.inductiveautomation.com/u/rbachman)\
**Post date:** [May 22, 2024, 10:21pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/1 "2024-05-22T22:21:51Z")

</div>

We're trying to upload a picture using the File Upload component and store it on a parameter in the view for later use to store to a database. The problem we're running into is that it appears that the Perspective parameter might be a string that refers to the object, and not the object itself. How do I use a string to retrieve the object itself?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/a/4a7179c963b5d2bab1432e0160a6fa8cdf657ea9.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 22, 2024, 10:24pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/2 "2024-05-22T22:24:49Z")

</div>

Tech tip: you're trying to store it on a **custom property** in the view - not a parameter. You might want to edit the original post to clarify.

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [May 22, 2024, 10:33pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/3 "2024-05-22T22:33:36Z")

</div>

If you really do want to store a file to a property value, you’ll need to string encode it somehow.

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [May 22, 2024, 10:40pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/4 "2024-05-22T22:40:23Z")

</div>

Unfortunately you can't store files in custom properties.

[This thread](https://forum.inductiveautomation.com/t/ignition-file-upload-component/79044) may be useful to you

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [May 22, 2024, 10:44pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/5 "2024-05-22T22:44:09Z")

</div>

Why not just go straight to the database?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 22, 2024, 11:38pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/6 "2024-05-22T23:38:51Z")

</div>

My Integration Toolkit has expression and scripting functions specifically to solve this problem, retaining original object identity in dictionaries attached to [session](https://www.automation-pros.com/toolkit/doc/scripting.html#sessionvarmap), [page](https://www.automation-pros.com/toolkit/doc/scripting.html#pagevarmap), or [view](https://www.automation-pros.com/toolkit/doc/scripting.html#viewvarmap) scopes.

These functions exist in my free module because Ignition's script wrappers for Perspective make it **impossible** (as far as I can tell) to construct weak references to sessions, pages, or views. In jython. Nearly trivial to do in a true java module.

With my module, you do not need to encode these objects at all--these features are compatible with unserializable objects.

(For the OP's case, the `pageVarMap()` is likely the best choice--workflows can change views without losing the stored objects.)

---

<div class="post-metadata">

**Author:** ![rbachman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rbachman/32/43718_2.png) [@rbachman](https://forum.inductiveautomation.com/u/rbachman)\
**Post date:** [May 23, 2024, 1:25pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/7 "2024-05-23T13:25:29Z")

</div>

> [@jlandwerlen](#):
>
> Why not just go straight to the database?

We have a form where the user is putting in new part information, and they have the option to upload a picture while they are entering the information. We can't write it to the database at the point that they upload the picture because the part doesn't exist in the database yet, so there is nothing to tie to the picture.

> [@amy.sudibyo](#):
>
> [This thread](https://forum.inductiveautomation.com/t/ignition-file-upload-component/79044) may be useful to you

We were able to get it working with `system.util.getGlobals()` from the thread you referenced. Thank you!!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 23, 2024, 1:33pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/8 "2024-05-23T13:33:46Z")

</div>

> [@rbachman](#):
>
> working with `system.util.getGlobals()`

I hope you use more than a view shutdown event to ensure things get cleaned up. Storing file contents in `.getGlobals()` is a potential memory leak waiting to bite you. And if done as naive as shown in that thread, a disaster across multiple users. At the very least, there should be a layers of dictionaries for session ID and page ID, with a gateway timer that deletes keys that are no longer in a session list.

---

<div class="post-metadata">

**Author:** ![Cole\_Townsend](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cole_townsend/32/53149_2.png) [@Cole\_Townsend](https://forum.inductiveautomation.com/u/Cole_Townsend)\
**Post date:** [May 24, 2024, 3:01pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/9 "2024-05-24T15:01:22Z")

</div>

> I hope you use more than a view shutdown event to ensure things get cleaned up. Storing file contents in `.getGlobals()` is a potential memory leak waiting to bite you. And if done as naive as shown in that thread, a disaster across multiple users. At the very least, there should be a layers of dictionaries for session ID and page ID, with a gateway timer that deletes keys that are no longer in a session list.

Oops... that was a major oversite on my part. I haven't even been using a view shutdown event to clear these out... I've been clearing them on the form submittal. I'm glad I saw this. I feel really dumb. Thanks @pturmel

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 24, 2024, 4:37pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/10 "2024-05-24T16:37:07Z")

</div>

It's really easy to forget things like this. Better to have a data structure that cleans up after users automatically.

---

<div class="post-metadata">

**Author:** ![rbachman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rbachman/32/43718_2.png) [@rbachman](https://forum.inductiveautomation.com/u/rbachman)\
**Post date:** [May 24, 2024, 5:00pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/11 "2024-05-24T17:00:20Z")

</div>

> [@pturmel](#):
>
> I hope you use more than a view shutdown event to ensure things get cleaned up. Storing file contents in `.getGlobals()` is a potential memory leak waiting to bite you.

We think we should be able to avoid a memory leak in our situation. We are removing the key every time that the view is closed. Also, in our particular case, we are sharing a key so that, at worst, we'll just overwrite a key that wasn't deleted rather than creating more and more keys that do not get deleted.

But I appreciate you mentioning this; we'll definitely keep an eye on it.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 24, 2024, 5:03pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/12 "2024-05-24T17:03:49Z")

</div>

> [@rbachman](#):
>
> we are sharing a key

So, no possible way to have two users on this form?

---

<div class="post-metadata">

**Author:** ![rbachman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rbachman/32/43718_2.png) [@rbachman](https://forum.inductiveautomation.com/u/rbachman)\
**Post date:** [May 24, 2024, 5:21pm UTC](https://forum.inductiveautomation.com/t/convert-object-reference-in-perspective-parameter-to-actual-object/90766/13 "2024-05-24T17:21:19Z")

</div>

> [@pturmel](#):
>
> So, no possible way to have two users on this form?

It's a limitation we're willing to deal with right now. 🤣

The team uploads pictures a handful of times each year, so we don't expect it to be a big issue. We'll go with something similar to what you suggested if we run into issues.
