Here’s a breakdown of what I have and what I’m trying to do:
Ignition version: 8.1. Module: Vision
- RootContainer (with ExpressionBinding)
- TemplateCanvas
- Template (w/ CustomProperty)
- Container
- TextField (w/ PropertyChange script)
- Container
- Template (w/ CustomProperty)
- TemplateCanvas
I have a TemplateCanvas with a Template that has a TextField. On that TextField, I have PropertyChange event script that I’m trying to use to update my CustomProperty on the Template.
Here’s the relevant portion of my script so far:
if event.propertyName == 'text':
event.source.parent.parent.CustomProperty = "CustomProperty: " + event.newValue.strip()
No matter what I’ve tried, the CustomProperty doesn’t get changed in the Templates dataset on the TemplateCanvas when the event is triggered. I can print event.source.parent.parent.CustomProperty right after updating its value and the print statement correctly reflects the update, but the CustomProperty in the Templates dataset doesn’t.
To further complicate things, I pull multiple of these CustomProperties and concatenate them in an ExpressionBinding to build a SQL query. For that ExpressionBinding, I’m using jsonGet to interpret the Parameters from the Templates dataset on the TemplateCanvas. But without the PropertyChange updating the dataset, I’m getting nowhere.
I’ve also tried tackling the problem by changing the ExpressionBinding, but I can’t seem to access the CustomProperty on the Template within the Canvas, only through the Parameters column in the Templates dataset. (See below for my expression binding.)
jsonGet({RootContainer.TemplateCanvas.templates}[0,"parameters"],"CustomProperty") + ' ' + jsonGet({RootContainer.TemplateCanvas.templates}[1,"parameters"],"CustomProperty")
What’s the solution here? Is there a way to use a PropertyChange script to update a CustomProperty in the Parameters of a TemplateCanvas? Or is there another way to access the CustomProperty on the TemplateInstance without going through the Parameters in the Templates dataset?