Use EngUnit and FormatString in a template

I am working on my first project in ignition. I have gone through a couple dozen IA university videos and searched the forum to no avail, so here is my first post:

I would like to make a template that has a label string and a numeric value that is displayed with the proper format and units. I have created a custom property for the template called LabelString and bound the label’s Text property to the the Templates LabelString property. So far so good.

Now I need to bind the tag from the PLC to the template’s Numeric Label so that the value is displayed. I can create a Custom Property template parameter of type double called TagValue and pass in the numeric value of the tag and bind the Numeric Label value to the template’s TagValue property.

What I can’t figure out how to do is also bind the Numeric Label component Units property to the tag’s EngUnit property by referring to the tag I have already bound. It is as if the tag value is passed to the template instead of the tag object, so I have to bind all of the tag properties (EngUnit, FormaString) each time I use the template, instead of passing in the object (tag) and accessing its properties within the template.

A co-worker has found that we can make a custom property of type String in the template called TagPath, when we use the template on a page we bind TagPath to an expression which is just a string containing the tag path, and then in the template use indirect tags to bind to {1}.EngUnit, {1}.value, {1}.FormatString, where {1} is a reference to TemplateName.TagPath. Is this the “right” way?

These topics seem to be related, but we aren’t using UDTs and it seems inconclusive as to whether or not that is the best approach:



1 Like

Yes, I believe the way most do that is by passing just the tag path and then getting everything else from it, though I’m curious if anyone does it differently. So for this template w/ the label & numeric label, you’d have two parameters (or more of course if you have other needs) one label, one tagPath, just pass it the tag path and it’ll get all it needs for each instance of the template.

is the best way to pass tagPath by binding to an expression containing the tagPath as a string?

The most efficient way to refer to a few sub-properties is by passing the tag path as a string into the template, and then using indirect tag bindings to get whatever values you need within the template.

2 Likes

Thanks PGriffith. As we are starting the process of re-creating the screens from a previous project in Ignition for our next project we are looking to make sure we do things the right way from the beginning since future projects will recycle the work we are doing now.

Is there a particular IA university video or section in the manual that covers this as a best practice? Maybe there will be some other information in the same section that will also guide us in the right direction