# Access Template RootContainer's custom Property

**URL:** <https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361>\
**Category:** Ignition\
**Created:** [December 2, 2019, 2:09pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361 "2019-12-02T14:09:56Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2019, 2:09pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/1 "2019-12-02T14:09:56Z")

</div>

I am trying to excess the custom property of template from script library. Here’s the snapshot -

I have the main window named - MainAguas

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/126f6e670a53517dcbf240d37d77c73c2f167616.png)

The template is something like this

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/57a137781a580617cb9b577d5e388d7d43ac9f28.png)

root container of this template has a custom properties as -

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/9fc263830d5dfa5506defb056d430e4fc483ddb1.png)

I am trying to write to the properties from global script library as -

```auto
def updatePage(machine, testMachine, compound, orderNumber, batchNumber):
	if machine == testMachine :
# try:
		
	    window = system.gui.getWindow("MainAguas")
		mainContainer = window.getRootContainer().getComponent("MDR 2")
		mainContainer.setPropertyValue("Root Container.compound", "DM M14")

```

I tried this is it doesn’t give any error but doesn’t update the client either.

Thanks

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2019, 3:34pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/2 "2019-12-02T15:34:30Z")

</div>

anyone ?

---

<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:** [December 2, 2019, 3:57pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/3 "2019-12-02T15:57:24Z")

</div>

Move the property to a custom property on the template itself and it will be available as a parameter when used in a window.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2019, 4:19pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/4 "2019-12-02T16:19:42Z")

</div>

I did that but it doesn’t update my component value automatically !! I have to update the whole project to see the component value updated on client !!

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 2, 2019, 4:20pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/5 "2019-12-02T16:20:56Z")

</div>

What @MMaynard said. Custom properties of templates aren’t accessible to the outside when you instantiate the template on a window, only parameters are. Custom properties should be used to help with any data calculations etc internal to the template. For any in/out data flow to the template, make it a parameter.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2019, 4:23pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/6 "2019-12-02T16:23:49Z")

</div>

@bkarabinchak.psi - I am using this (parameter on the template or custom property on root container) to update the value of the components in a template. when I changed it to parameter, it does right to the property but I do not see the component value change on the client screen !!

Once, I save the project, then it’s there !

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 2, 2019, 4:27pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/7 "2019-12-02T16:27:20Z")

</div>

Oh yes, to see your changes you do need to Save and Publish changes otherwise the changes will never get pushed to your project. It’s all working correctly now?

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2019, 4:31pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/8 "2019-12-02T16:31:40Z")

</div>

@bkarabinchak.psi. I have a gateway timer which looks for a text file in the specific directory on server ! whenever there is a new file, I am reading that in a global script and pushing the value to database. Also, after reading the file, I am trying to push the values to this template parameters depending on what template is it intended for. Hence, the client should automatically update those values on screen whenever there is a new file !!

I hope you understood the scenario !

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 2, 2019, 4:54pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/9 "2019-12-02T16:54:03Z")

</div>

> [@kaushik.shah](#):
>
> setPropertyValue

I think your issue might be using this function to write to the parameter.

Try using setattr instead as in Phil's post here:

> [@Function to set component property](http://forum.inductiveautomation.com/t/function-to-set-component-property/15074/3):
>
> Why wouldn’t one just use python’s setattr() function? Like so: def setPropertyValue(comp, prop, val): setattr(comp, prop, val) Consider catching AttributeError, though, to fall back on the setPropertyValue() method applicable to custom properties (not always supported by setattr). Like so: def setPropertyValue(comp, prop, val): try: setattr(comp, prop, val) except AttributeError: return comp.setPropertyValue(prop, val)

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2019, 5:02pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/10 "2019-12-02T17:02:37Z")

</div>

@nminchin Tried that !! Still doesn’t update the component value on client screen !!

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 2, 2019, 5:04pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/11 "2019-12-02T17:04:47Z")

</div>

What about binding that property to a client tag?

---

<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:** [December 2, 2019, 5:08pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/12 "2019-12-02T17:08:56Z")

</div>

You cannot access a client scope from the gateway like that as it doesn’t have access to windows.  
Create a Memory tag and have the script write the value to the tag and then have the template read the tag for the value.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 2, 2019, 5:10pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/13 "2019-12-02T17:10:54Z")

</div>

I was just about to edit my post with that; you beat me to it. Still, it should be possible via the method OP is using though, I just don’t know enough about the back end mechanisms…

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2019, 5:22pm UTC](https://forum.inductiveautomation.com/t/access-template-rootcontainers-custom-property/30361/14 "2019-12-02T17:22:29Z")

</div>

Okay !! trying to create a UDT instance and read from there to a custom property !
