# Get Tagpath via scripting

**URL:** <https://forum.inductiveautomation.com/t/get-tagpath-via-scripting/78541>\
**Category:** General Discussion\
**Created:** [August 30, 2023, 1:31am UTC](https://forum.inductiveautomation.com/t/get-tagpath-via-scripting/78541 "2023-08-30T01:31:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henrol\_Jeo\_Gutierrez](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/henrol_jeo_gutierrez/32/50993_2.png) [@Henrol\_Jeo\_Gutierrez](https://forum.inductiveautomation.com/u/Henrol_Jeo_Gutierrez)\
**Post date:** [August 30, 2023, 1:31am UTC](https://forum.inductiveautomation.com/t/get-tagpath-via-scripting/78541/1 "2023-08-30T01:31:48Z")

</div>

I have a label component that when I click on it, it will write data to specific OPC tags.  
What I want is to get the source's tag path via the event.source to use it in system.gui.tag.writeBlocking("tagPath", "valueToWrite")

```auto
val = system.gui.inputBox("Insert Value","Numeric only")
path = event.source.GetTagPath // But I am not sure how can I get the tagpath dynamically.

system.gui.tag.writeBlocking(path, val)

```

Hoping for your help.

Regards

---

<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:** [August 30, 2023, 1:43am UTC](https://forum.inductiveautomation.com/t/get-tagpath-via-scripting/78541/2 "2023-08-30T01:43:00Z")

</div>

How does the label know the tagpath? Did you bind to a tag? If so, is there any reason you don't want to use a bidirectional binding? (That would be the supported technique--simply write to the component property with the bidirectional binding, which will send it to the tag for you.)

---

<div class="post-metadata">

**Author:** ![Henrol\_Jeo\_Gutierrez](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/henrol_jeo_gutierrez/32/50993_2.png) [@Henrol\_Jeo\_Gutierrez](https://forum.inductiveautomation.com/u/Henrol_Jeo_Gutierrez)\
**Post date:** [August 30, 2023, 2:12am UTC](https://forum.inductiveautomation.com/t/get-tagpath-via-scripting/78541/3 "2023-08-30T02:12:33Z")

</div>

Hi @pturmel

Thanks for the swift response.  
And yes, the tag is already binded to the label component bidirectionally.

What I want is when I click the label component, it opens up an inputbox where the user will input value to write in a tag.

I can actually write on it specifying the tagpath in the script, however I am thinking if there is a way to automate it radther than coding it manually.

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:** [August 30, 2023, 2:15am UTC](https://forum.inductiveautomation.com/t/get-tagpath-via-scripting/78541/4 "2023-08-30T02:15:07Z")

</div>

```auto
system.gui.tag.writeBlocking(path, val)

```

This is not a system function, the correct one would be `system.tag.writeBlocking()`.  
Though technically supported with a single string and value, the function actually calls for lists, which you are not supplying.

the source of the event is a component, and has no idea of the tag path in the traditional since.

As @pturmel says, use a bi-directional binding. Not only is it the supported method, but it will be faster as well.

> [@Henrol\_Jeo\_Gutierrez](#):
>
> What I want is when I click the label component, it opens up an inputbox where the user will input value to write in a tag.

Use a popup with a text field component that is bi-directionally bound to the tag. Remove the bi-directional binding on the label.

---

<div class="post-metadata">

**Author:** ![Henrol\_Jeo\_Gutierrez](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/henrol_jeo_gutierrez/32/50993_2.png) [@Henrol\_Jeo\_Gutierrez](https://forum.inductiveautomation.com/u/Henrol_Jeo_Gutierrez)\
**Post date:** [August 30, 2023, 2:27am UTC](https://forum.inductiveautomation.com/t/get-tagpath-via-scripting/78541/5 "2023-08-30T02:27:52Z")

</div>

Thanks for the Tip!  
And yes, I stand corrected about the script, it should be system.tag.writeBlocking

One more question, is it possie to pass the tag binding or tagpath as parameter in the pop-up menu?

Thanks and 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:** [August 30, 2023, 2:30am UTC](https://forum.inductiveautomation.com/t/get-tagpath-via-scripting/78541/6 "2023-08-30T02:30:50Z")

</div>

Yes you can pass the tag path to the popup as a parameter. Then you can (and arguably should) use an indirect tag binding on the text box.
