# Referencing a custom property using variable

**URL:** <https://forum.inductiveautomation.com/t/referencing-a-custom-property-using-variable/66538>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [November 15, 2022, 5:51pm UTC](https://forum.inductiveautomation.com/t/referencing-a-custom-property-using-variable/66538 "2022-11-15T17:51:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salem\_Marshall](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Salem\_Marshall](https://forum.inductiveautomation.com/u/Salem_Marshall)\
**Post date:** [November 15, 2022, 5:51pm UTC](https://forum.inductiveautomation.com/t/referencing-a-custom-property-using-variable/66538/1 "2022-11-15T17:51:58Z")

</div>

I want to run the same python code for several custom properties in a vision window on a triggered action. All of the custom properties are a dataset, so I want to pull that data into a variable called "rawData" and then run the code against that data.

In order to avoid copying & pasting repetitive code, I wanted to try building the custom property names as a string and then running the code in a loop. The issue I am running into is I can't figure out how to reference a custom property according to a string name. I pasted the segment of code below. Any help would be appreciated, thanks!

For reference there are 22 custom properties: base2 - base8, cush1 - cush8, pill1 - pill7

```
	for i in range(3):
		if i == 0:
			component = "base"
			numStations = 7
		elif i == 1:
			component = "cush"
			numStations = 8
		else:
			component = "pill"
			numStations = 7
		
		for j in range(numStations):
			if i != 0:
				station = str(component + str(j+1))
			else:
				station = str(component + str(j+2))
			stationData = "event.source.parent." + station
			rawData = stationData
                            #and then this is where the code would go that references the raw data

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 15, 2022, 5:54pm UTC](https://forum.inductiveautomation.com/t/referencing-a-custom-property-using-variable/66538/2 "2022-11-15T17:54:33Z")

</div>

Use [`getattr`](https://docs.python.org/2.7/library/functions.html#getattr) to dynamically reference an attribute.

---

<div class="post-metadata">

**Author:** ![Salem\_Marshall](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Salem\_Marshall](https://forum.inductiveautomation.com/u/Salem_Marshall)\
**Post date:** [November 15, 2022, 5:56pm UTC](https://forum.inductiveautomation.com/t/referencing-a-custom-property-using-variable/66538/3 "2022-11-15T17:56:33Z")

</div>

Perfect! Thanks so much
