# Perspective Write Label Data to Memory Tag

**URL:** <https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270>\
**Category:** Ignition\
**Tags:** perspective, scripting, ignition80\
**Created:** [February 10, 2021, 10:55pm UTC](https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270 "2021-02-10T22:55:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jon.smith](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jon.smith](https://forum.inductiveautomation.com/u/jon.smith)\
**Post date:** [February 10, 2021, 10:55pm UTC](https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270/1 "2021-02-10T22:55:42Z")

</div>

What is the best method to write to a memory tag in Perspective using a Gateway Event on a Timer? I’m trying to write property values on a View to a Memory Tag every 30 seconds. I was able to get it working with a button click:

path0 = “[default]HXL\_7205/JobDetails\_7205/sfOrderNumber”  
tagVal0 = self.getSibling(“lbl\_7205\_OrderNumber”).props.text  
system.tag.writeAsync([path0],[tagVal0],runAction)

But now I’d like to do it at the Gateway level and without user interaction. I don’t know how to reference the View where the label is located. Any ideas?

---

<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:** [February 11, 2021, 11:14am UTC](https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270/2 "2021-02-11T11:14:40Z")

</div>

> [@jon.smith](#):
>
> I don’t know how to reference the View where the label is located

You can't. Imagine there could be 100s of clients open at once, which client would the gateway use? It's impossible for the gateway to access anything from a client without the client initiating it.  
Can you explain why you want to write the values of the fields on the screen to memory tags periodically? What is the end goal? Perhaps there's a better way to do what you're wanting

---

<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:** [February 11, 2021, 1:29pm UTC](https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270/3 "2021-02-11T13:29:33Z")

</div>

Sounds like you need a bi-directional binding.

---

<div class="post-metadata">

**Author:** ![jon.smith](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jon.smith](https://forum.inductiveautomation.com/u/jon.smith)\
**Post date:** [February 11, 2021, 2:39pm UTC](https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270/4 "2021-02-11T14:39:28Z")

</div>

I’m grabbing data from a vendor database via named query with parameters and then assigning it to a label with polling. So as the data changes I’d like to have a timer that runs on the gateway looks at that specific perspective view and label value and then writes the label value to a memory tag.

How would I setup bi directional tag?

---

<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:** [February 11, 2021, 3:27pm UTC](https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270/5 "2021-02-11T15:27:38Z")

</div>

> [@jon.smith](#):
>
> timer that runs on the gateway looks at that specific perspective view

That view exists in client scope, if it exists at all. Not readable from a gateway timer script. If this needs to be live all the time, you should be running the named query in the gateway timer script and writing to the memory tag there. Then the client view(s) that care can just display the memory tag.

---

<div class="post-metadata">

**Author:** ![jon.smith](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jon.smith](https://forum.inductiveautomation.com/u/jon.smith)\
**Post date:** [February 11, 2021, 5:33pm UTC](https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270/6 "2021-02-11T17:33:59Z")

</div>

Looks like I’m able to use a Transform on the label and add my script there to write the value to the memory tag.

---

<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:** [February 11, 2021, 7:13pm UTC](https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270/7 "2021-02-11T19:13:35Z")

</div>

What happens when the page isn't being displayed in a client? Do you need the memory tags to be updated then?

> [@jon.smith](#):
>
> How would I setup bi directional tag?

You just need to bind the fields to your memory tags and check the "bi-directional" checkbox. This will then write the value changed on the bound property back to the bound tag

---

<div class="post-metadata">

**Author:** ![jon.smith](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jon.smith](https://forum.inductiveautomation.com/u/jon.smith)\
**Post date:** [February 13, 2021, 6:27pm UTC](https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270/8 "2021-02-13T18:27:32Z")

</div>

Technically yes…, the machine center will run as a kiosk so the view should always be running. However, there may be times when it is not. Is there a better way to write the tag data when the view isn’t open?

---

<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:** [February 13, 2021, 6:30pm UTC](https://forum.inductiveautomation.com/t/perspective-write-label-data-to-memory-tag/43270/9 "2021-02-13T18:30:30Z")

</div>

Yes, four comments up.
