# Dynamic binding tag to template custom property

**URL:** <https://forum.inductiveautomation.com/t/dynamic-binding-tag-to-template-custom-property/87783>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [March 22, 2024, 11:07pm UTC](https://forum.inductiveautomation.com/t/dynamic-binding-tag-to-template-custom-property/87783 "2024-03-22T23:07:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Szilagyi](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@Michael\_Szilagyi](https://forum.inductiveautomation.com/u/Michael_Szilagyi)\
**Post date:** [March 22, 2024, 11:07pm UTC](https://forum.inductiveautomation.com/t/dynamic-binding-tag-to-template-custom-property/87783/1 "2024-03-22T23:07:45Z")

</div>

I'd like to be able to dynamically bind a tag to a custom property in a template so it can be accessed from a script within that template. The dynamically created tag change event directly executing a script within a template would be fine, too. Basically I have a bunch of conveyor shape templates (straight, 90 degree curve, 45 degree curve, etc) that all use the same color animation. I'd like to not have to maintain that same color animation script separately for each shape template, so I want to pull it out to a single script I can reference in all my templates via nested templates or otherwise. The current logic is below.

case(tag("[default]"+ {MDRZoneSingulate.panelName} + "/"+ {MDRZoneSingulate.conveyorName} + "\_Status"),0,"Gray",1,"green",2,"red",3,"Yellow",4,"blue",5,"Gray","purple")

Thanks,  
Michael

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 22, 2024, 11:12pm UTC](https://forum.inductiveautomation.com/t/dynamic-binding-tag-to-template-custom-property/87783/2 "2024-03-22T23:12:00Z")

</div>

Make a custom property on the template for only the tag value, and then indirectly bind that to your target tag. ~~Then, in another custom property, have your case statement inspect the value of the custom property that has the tag value. Pass the panel name and conveyor name into the template and use them for the indirect binding.~~ Man its a friday. 🙃

In a second property's binding, use an expression that uses `lookup` to look at a global dataset tag that has the colors/status numbers defined. Something along the lines of:

```python
lookup(
	{path.to.global.colors.tag},
	{this.custom.conveyorStatus},
	"black",
	"Status",
	"Color"
)

```

If you need to update colors, just adjust that global dataset.

> [@Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831):
>
> This thread is intended as a short help file for all those struggling to post formatted code on the forum. Code block formatting Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the \</\> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting. [How to post code] Note that all the \</\> button does is add three backticks ``` on the line before the code block and anot…

Browsing the [manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/working-with-perspective-components/bindings-in-perspective/tag-bindings-in-perspective#indirect-tag-binding-mode) might help.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 22, 2024, 11:42pm UTC](https://forum.inductiveautomation.com/t/dynamic-binding-tag-to-template-custom-property/87783/3 "2024-03-22T23:42:58Z")

</div>

That's what internal template properties are intended for. Template properties themselves are expected to be supplied by the containing component. Internal properties are where you can create and bind subexpressions for the template's internal use. (And have property change event functionality.)

---

<div class="post-metadata">

**Author:** ![Michael\_Szilagyi](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@Michael\_Szilagyi](https://forum.inductiveautomation.com/u/Michael_Szilagyi)\
**Post date:** [March 23, 2024, 12:02am UTC](https://forum.inductiveautomation.com/t/dynamic-binding-tag-to-template-custom-property/87783/5 "2024-03-23T00:02:20Z")

</div>

Figured out that you can only bind to internal properties which defeats what I was trying to do. I like the lookup to the dataset for this particular case, but would really like to be able to call something like a function to handle future use cases. Just getting my arms wrapped around Ignition and I feel like I'm typing with my elbows. Off to try to find function calls/definitions or something in the manual.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![Michael\_Szilagyi](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@Michael\_Szilagyi](https://forum.inductiveautomation.com/u/Michael_Szilagyi)\
**Post date:** [March 23, 2024, 12:04am UTC](https://forum.inductiveautomation.com/t/dynamic-binding-tag-to-template-custom-property/87783/6 "2024-03-23T00:04:01Z")

</div>

Where are you supposed to put code that you want to use in multiple templates?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 23, 2024, 2:28am UTC](https://forum.inductiveautomation.com/t/dynamic-binding-tag-to-template-custom-property/87783/7 "2024-03-23T02:28:58Z")

</div>

In the project script library.

IMNSHO, _ **every** _ event and component method should be a one-line statement delegating to a function in a project script.
