# Dynamic Custom Property Path

**URL:** <https://forum.inductiveautomation.com/t/dynamic-custom-property-path/52267>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 23, 2021, 2:50am UTC](https://forum.inductiveautomation.com/t/dynamic-custom-property-path/52267 "2021-10-23T02:50:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hcrowe](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@hcrowe](https://forum.inductiveautomation.com/u/hcrowe)\
**Post date:** [October 23, 2021, 2:50am UTC](https://forum.inductiveautomation.com/t/dynamic-custom-property-path/52267/1 "2021-10-23T02:50:29Z")

</div>

Hello I am fairly new to ignition and the scripting language. I have a project I am working on which involves a template with 45 custom properties I need to write values from an excel file. I’m using the mousePressed event handler to loop through an array of values from the excel file. Then I would like to iterate through the custom properties. Is this possible?  
Example: I have the following tag path: _event.source.parent.parent.parent.parent.parent.MixPage1\_Line1_

I would like to:  
for i in range(45):  
event.source.parent.parent.parent.parent.parent.MixPage1\_Line{i} = value

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [October 23, 2021, 6:10am UTC](https://forum.inductiveautomation.com/t/dynamic-custom-property-path/52267/2 "2021-10-23T06:10:22Z")

</div>

Sure, this is simple to do. Here an example:

First a template with some custom properties:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/8/58da5793417b7b6fd36a3e252e7feda1401631f8.png)

Then add the script on mousePressed self template, but it can be anywhere as long it can refer to template properties:

```auto
properties = event.source.getDynamicProps().values()
newValues = {'property1':2,'property2':'newString','property3':False,'property4':7.1}#new values dictionary
for p in properties:
	property = p.toString()
	print property,' oldValue: ',event.source.getPropertyValue(property) #get old value
	event.source.setPropertyValue(property,newValues[property]) #set new value, must be same datatype
	print property,' newValue: ',event.source.getPropertyValue(property) #get new value

```

So basically I created a new values dictionary which keys are property names and new values.

Run the script and see results

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/d/ed4387c7bab3f71cd87741a065a91e86889efd9e.png)

---

<div class="post-metadata">

**Author:** ![hcrowe](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@hcrowe](https://forum.inductiveautomation.com/u/hcrowe)\
**Post date:** [October 23, 2021, 1:03pm UTC](https://forum.inductiveautomation.com/t/dynamic-custom-property-path/52267/3 "2021-10-23T13:03:14Z")

</div>

Thanks jespinmartin1 I will give that a try and let you know how it goes.

---

<div class="post-metadata">

**Author:** ![hcrowe](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@hcrowe](https://forum.inductiveautomation.com/u/hcrowe)\
**Post date:** [October 23, 2021, 4:48pm UTC](https://forum.inductiveautomation.com/t/dynamic-custom-property-path/52267/4 "2021-10-23T16:48:06Z")

</div>

Worked like a charm thanks for the assistance.
