Access Template RootContainer's custom Property

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

I have the main window named - MainAguas


The template is something like this


root container of this template has a custom properties as -

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

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.


anyone ?

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

1 Like

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 !!

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.

@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 !

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?

@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 !

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

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

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

What about binding that property to a client tag?

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.

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…

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