# Use EngUnit and FormatString in a template

**URL:** <https://forum.inductiveautomation.com/t/use-engunit-and-formatstring-in-a-template/16098>\
**Category:** Ignition\
**Created:** [November 22, 2017, 6:16pm UTC](https://forum.inductiveautomation.com/t/use-engunit-and-formatstring-in-a-template/16098 "2017-11-22T18:16:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joeyjojoshabadu](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@joeyjojoshabadu](https://forum.inductiveautomation.com/u/joeyjojoshabadu)\
**Post date:** [November 22, 2017, 6:16pm UTC](https://forum.inductiveautomation.com/t/use-engunit-and-formatstring-in-a-template/16098/1 "2017-11-22T18:16:16Z")

</div>

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:

> [@Displaying Metadata For a Tag in a Template](http://forum.inductiveautomation.com/t/displaying-metadata-for-a-tag-in-a-template/4438):
>
> I have a template I’m trying to build using the standard numeric display from the toolbox. In the graphic, I’m trying to display the process variable along with the engr. units. When I try to bind the units field of the display to the engr. units dot field of a UDT, I get the following error: “You must choose a bound property in the tree.” I’m able to do this if I bind directly to the “.EngUnit” dot field of a tag. I have attached a couple screenshots of what exactly I’m looking at as far a…

> [@Template using UDT param: Can you access UDT tag metadata?](http://forum.inductiveautomation.com/t/template-using-udt-param-can-you-access-udt-tag-metadata/10179/5):
>
> I would always use the tag path way and would avoid using UDT template parameters altogether. I’ve been bitten before when a new UDT was created which was fairly similar and I wanted to reuse the same templates and detail pages, but due to the template and page using a pre-defined UDT parameter, I couldn’t. I ended up re-coding these templates and pages to instead use the tag path which allows a lot more flexibility in the future for reuse.

> [@Templates and udt tags](http://forum.inductiveautomation.com/t/templates-and-udt-tags/10405):
>
> We have recently discovered that when a template access a udt that all of the tags within the udt are subscribed/polled even if they are not referenced in the template. Our project uses an object oriented approach and our objects/udts can be large. For example, say we have a valve object that has all tags associated with the valve including indications, controls, setpoints, actuation timers, alarms, etc… The number of tags can easily exceed 200 for some of our objects. If just a single tag w…

---

<div class="post-metadata">

**Author:** ![mrogers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mrogers/32/4110_2.png) [@mrogers](https://forum.inductiveautomation.com/u/mrogers)\
**Post date:** [November 22, 2017, 6:25pm UTC](https://forum.inductiveautomation.com/t/use-engunit-and-formatstring-in-a-template/16098/2 "2017-11-22T18:25:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joeyjojoshabadu](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@joeyjojoshabadu](https://forum.inductiveautomation.com/u/joeyjojoshabadu)\
**Post date:** [November 22, 2017, 6:28pm UTC](https://forum.inductiveautomation.com/t/use-engunit-and-formatstring-in-a-template/16098/3 "2017-11-22T18:28:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 22, 2017, 7:56pm UTC](https://forum.inductiveautomation.com/t/use-engunit-and-formatstring-in-a-template/16098/4 "2017-11-22T19:56:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joeyjojoshabadu](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@joeyjojoshabadu](https://forum.inductiveautomation.com/u/joeyjojoshabadu)\
**Post date:** [November 22, 2017, 8:19pm UTC](https://forum.inductiveautomation.com/t/use-engunit-and-formatstring-in-a-template/16098/5 "2017-11-22T20:19:31Z")

</div>

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
