# Bound Tag Path from Display Component in Script

**URL:** <https://forum.inductiveautomation.com/t/bound-tag-path-from-display-component-in-script/9675>\
**Category:** General Discussion\
**Created:** [February 6, 2015, 7:44pm UTC](https://forum.inductiveautomation.com/t/bound-tag-path-from-display-component-in-script/9675 "2015-02-06T19:44:41Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![camatt3](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@camatt3](https://forum.inductiveautomation.com/u/camatt3)\
**Post date:** [June 7, 2018, 3:09am UTC](https://forum.inductiveautomation.com/t/bound-tag-path-from-display-component-in-script/9675/4 "2018-06-07T03:09:22Z")

</div>

I altered the script to recursively check property bindings.  
So if property1 is bound to property2, and property2 is bound to a tag, calling the script for property1 will return the tag path on property2.

```auto
# --------------------------------------------------------------------------
# Get the path of the tag that a component's property is bound to.
# --------------------------------------------------------------------------
def getTagForProperty(component, property="value"):
	# Get the window for this component
	window = component
	while window != None and not window.class.simpleName in ("FPMIWindow", "VisionTemplate"):
		# Keep checking the parent until we find a window (or template)
		window = window.parent
		
	if window != None:		
		# Get the binding adapter on the window for the given component and property.
		ic = window.getInteractionController()
		adapter = ic.getPropertyAdapter(component, property)
		
		if adapter != None:
			# Simple Tag Binding
			if adapter.class.simpleName == "SimpleBoundTagAdapter":
				return adapter.getTagPathString()
			# Indirect Tag Binding
			elif adapter.class.simpleName == "IndirectTagBindingAdapter":
				# Parse the indirect tag path
				interactions = adapter.getInteractions()
				ss = [] # List of parts of the string that will be returned
				for p in adapter.getPathParts():
					idx = p.getRefIdx()
					if idx > 0:
						# Get the current value of indirect bindings
						ss.append(interactions[idx - 1].getQValue().value)
					else:
						# Get static strings
						ss.append(p.getString())
				return "".join(ss)
			# Property Binding
			elif adapter.class.simpleName == "SimpleBoundPropertyAdapter":
				interaction = adapter.getInteraction()
				# Recursively check if source property is bound to a tag
				return getTagForProperty(interaction.getSource(), interaction.getSourceProperty())
		
	# Return None if no tag binding was found
	return None

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/bound-tag-path-from-display-component-in-script/9675)._
