# Getting TagPath from Graphic Display Object

**URL:** <https://forum.inductiveautomation.com/t/getting-tagpath-from-graphic-display-object/9676>\
**Category:** Ignition\
**Created:** [February 7, 2015, 3:55pm UTC](https://forum.inductiveautomation.com/t/getting-tagpath-from-graphic-display-object/9676 "2015-02-07T15:55:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisGray](https://avatars.discourse-cdn.com/v4/letter/c/ba9def/32.png) [@ChrisGray](https://forum.inductiveautomation.com/u/ChrisGray)\
**Post date:** [February 7, 2015, 3:55pm UTC](https://forum.inductiveautomation.com/t/getting-tagpath-from-graphic-display-object/9676/1 "2015-02-07T15:55:56Z")

</div>

Is there a scripting method to get the Tag Path from a elementary graphic display object?

Example Graphic Object component:  
Numeric Label: Value attribute is say set to some tag with pathname “myPath\myTag” \<–Tag Path

In the event script for this object I would like to access the Tag Path name (string). Is this possible?

pseudo code might ideally be: event.source.displayPath

---

<div class="post-metadata">

**Author:** ![Paul.Scott](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.scott/32/4578_2.png) [@Paul.Scott](https://forum.inductiveautomation.com/u/Paul.Scott)\
**Post date:** [March 10, 2015, 11:31pm UTC](https://forum.inductiveautomation.com/t/getting-tagpath-from-graphic-display-object/9676/2 "2015-03-10T23:31:57Z")

</div>

Hello,

By “elementary graphic display object” are you referring to a component of some sort? If so then your pseudo code is correct if the scripting event is on that same component.

If you’re trying to access this from another component’s scripting event that is on the same container then you’ll need to use something like event.source.parent.propertyName

---

<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:** [March 11, 2015, 7:15pm UTC](https://forum.inductiveautomation.com/t/getting-tagpath-from-graphic-display-object/9676/3 "2015-03-11T19:15:28Z")

</div>

If my mind-reading skills are working, it sounds like you are after the tag path that is bound to a property? If so, use this:

`w = system.gui.getParentWindow(event)
pa = w.interactionController.getPropertyAdapter(event.source, 'value')
print pa
m = pa.class.getDeclaredMethod('getCurrentTagPath', [])
m.setAccessible(True)
print m.invoke(pa)`A couple comments:  
[ul][li]Bindings are not properties of the component – they are part of the window.[/li]  
[li]The getCurrentTagPath() method is protected, and java will normally not let you call it. So you have to jump through some hoops.[/li][/ul]

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [July 25, 2017, 7:05pm UTC](https://forum.inductiveautomation.com/t/getting-tagpath-from-graphic-display-object/9676/4 "2017-07-25T19:05:29Z")

</div>

Phil,  
Could this be used to drill down into a template instance and get the tag path of a control inside the template?  
I have dug around a bit, but can’t seem to get it to drill down and get the path.

Not using a repeater or canvas, just a template on a window.

---

<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:** [July 26, 2017, 4:31pm UTC](https://forum.inductiveautomation.com/t/getting-tagpath-from-graphic-display-object/9676/5 "2017-07-26T16:31:11Z")

</div>

It should work for an event on a component in the template. Drilling down into a template holder to find the component to pass to getPropertyAdapter() may require some introspection. Start [here](http://files.inductiveautomation.com/sdk/javadoc/ignition79/790-beta1/com/inductiveautomation/factorypmi/application/components/template/TemplateHolder.html).

---

<div class="post-metadata">

**Author:** ![jayvie.villaflores](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jayvie.villaflores](https://forum.inductiveautomation.com/u/jayvie.villaflores)\
**Post date:** [April 15, 2019, 5:27am UTC](https://forum.inductiveautomation.com/t/getting-tagpath-from-graphic-display-object/9676/6 "2019-04-15T05:27:35Z")

</div>

Hi, I just want to bring back this topic about drilling down into a template’s component to get tagPath bonded to it.

So, what I understand from previous conversation is that a window has this called Interaction Controller which handles all events from the components inside. However, a template will be treated as one component inside a window so I can’t get properties of all components inside the template.

I was able to get tagPath of the tag bonded to a component inside a window but not in a template.

Is there anyone who completed the code using template holder?

Any help would be appreciated. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![lucamaffeis](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lucamaffeis/32/10269_2.png) [@lucamaffeis](https://forum.inductiveautomation.com/u/lucamaffeis)\
**Post date:** [August 2, 2019, 7:04pm UTC](https://forum.inductiveautomation.com/t/getting-tagpath-from-graphic-display-object/9676/7 "2019-08-02T19:04:48Z")

</div>

I’ve written this code, and it works for me:

```auto
w = system.gui.getParentWindow(event)
c = event.source.parent.getInstanceName()

# gets the TemplateHolder component
i = w.rootContainer.getComponent(c)

pa = w.interactionController.getPropertyAdapter(i, 'TagLamp')

m = pa.class.getDeclaredMethod('getCurrentTagPath', []) 
m.setAccessible(True) 
print m.invoke(pa)

```

‘TagLamp’ is the name of the template parameter from which I want to extract the tagname linked to it.
