# Read tag value with a perspective component change script

**URL:** <https://forum.inductiveautomation.com/t/read-tag-value-with-a-perspective-component-change-script/58827>\
**Category:** Ignition\
**Tags:** scripting, ignition81, perspective\
**Created:** [April 25, 2022, 5:44pm UTC](https://forum.inductiveautomation.com/t/read-tag-value-with-a-perspective-component-change-script/58827 "2022-04-25T17:44:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hector\_Aaron\_Mani\_La](https://avatars.discourse-cdn.com/v4/letter/h/e79b87/32.png) [@Hector\_Aaron\_Mani\_La](https://forum.inductiveautomation.com/u/Hector_Aaron_Mani_La)\
**Post date:** [April 25, 2022, 5:44pm UTC](https://forum.inductiveautomation.com/t/read-tag-value-with-a-perspective-component-change-script/58827/1 "2022-04-25T17:44:49Z")

</div>

Hi everyone;

I am working with a Label and I have created a text change script as seen below:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/0/00e10d4e56c034395e9483fa9227e6a1080e1f83.png)

And I would like to read the value of a tag that is bound to a PLC. is that posible with the system.read.Async? or there is another way to read a tag value?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/b/4b119eaca215f38182c4300135bd58866d694af6.png)

Best regards

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 25, 2022, 6:14pm UTC](https://forum.inductiveautomation.com/t/read-tag-value-with-a-perspective-component-change-script/58827/2 "2022-04-25T18:14:45Z")

</div>

It is possible, but I doubt that you actually want `readAsync` in this case. I assume that you are wanting to read the value to be used later on in the script?

```auto
tagValue = system.tag.readBlocking(['[YourProvider]YourTagPath'])[0].value

```

---

<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:** [April 25, 2022, 6:42pm UTC](https://forum.inductiveautomation.com/t/read-tag-value-with-a-perspective-component-change-script/58827/3 "2022-04-25T18:42:17Z")

</div>

`tagValue = system.tag.readBlocking(['[YourProvider]YourTagPath'])[0].value`

Though I kinda feel we have an [xy situation](https://en.wikipedia.org/wiki/XY_problem) here.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 25, 2022, 6:45pm UTC](https://forum.inductiveautomation.com/t/read-tag-value-with-a-perspective-component-change-script/58827/4 "2022-04-25T18:45:35Z")

</div>

Yeah, very possible. I rarely use a one line tag read like that so I seem to always for get to add the member reference.

Thanks,

---

<div class="post-metadata">

**Author:** ![Hector\_Aaron\_Mani\_La](https://avatars.discourse-cdn.com/v4/letter/h/e79b87/32.png) [@Hector\_Aaron\_Mani\_La](https://forum.inductiveautomation.com/u/Hector_Aaron_Mani_La)\
**Post date:** [April 25, 2022, 6:58pm UTC](https://forum.inductiveautomation.com/t/read-tag-value-with-a-perspective-component-change-script/58827/5 "2022-04-25T18:58:27Z")

</div>

It doesn’t works

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

i want that every time that I press this button, read the tag value (wich is an integer data type) and assigne to the label

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 25, 2022, 7:27pm UTC](https://forum.inductiveautomation.com/t/read-tag-value-with-a-perspective-component-change-script/58827/6 "2022-04-25T19:27:33Z")

</div>

There is no error in the script that I can see that would make it write the value of the tag to the text property. Are you getting an error reported?

If this is on a button, then the script should be in the actionPerformed event, not in a value changed script.

---

<div class="post-metadata">

**Author:** ![Hector\_Aaron\_Mani\_La](https://avatars.discourse-cdn.com/v4/letter/h/e79b87/32.png) [@Hector\_Aaron\_Mani\_La](https://forum.inductiveautomation.com/u/Hector_Aaron_Mani_La)\
**Post date:** [April 25, 2022, 8:35pm UTC](https://forum.inductiveautomation.com/t/read-tag-value-with-a-perspective-component-change-script/58827/7 "2022-04-25T20:35:05Z")

</div>

Youe are right, I was doing it wrong. thaks a lot!
