# Functions for background

**URL:** <https://forum.inductiveautomation.com/t/functions-for-background/89131>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [April 19, 2024, 5:36pm UTC](https://forum.inductiveautomation.com/t/functions-for-background/89131 "2024-04-19T17:36:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alfredo\_Egmo](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Alfredo\_Egmo](https://forum.inductiveautomation.com/u/Alfredo_Egmo)\
**Post date:** [April 19, 2024, 5:36pm UTC](https://forum.inductiveautomation.com/t/functions-for-background/89131/1 "2024-04-19T17:36:00Z")

</div>

Is there a way in ignition to create kind of a function that will receive parameters as the value of a tag and inside of that function it will compare the value with other tag values(limits) and depending of that logic it should return a "color" to be assigned as example to the background of a box. Inside of the function I need to receive some parametrs that will be used in the logic of the function, the logic inside of that function will have more than 4 comparisons to properly select the color to return.

Note , the intention of this function is to be utilized by several controls on screen that have to paint the background depending of the value and limits, so if the logic changes I only have to change it in one place.

---

<div class="post-metadata">

**Author:** ![Steve\_Laubach](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steve_laubach/32/60900_2.png) [@Steve\_Laubach](https://forum.inductiveautomation.com/u/Steve_Laubach)\
**Post date:** [April 19, 2024, 5:49pm UTC](https://forum.inductiveautomation.com/t/functions-for-background/89131/2 "2024-04-19T17:49:43Z")

</div>

I think you're describing the functionality of templates.

In vision you can create templates and add custom properties to them which function as parameters. You can also pass in parameters that are partial tag paths that can be used in indirect tag bindings.

Imagine a scenario where you have 20 pumps that are all animated using the same type of logic. You can create a UDT or organize your tags in folders where the tags in the folders have the same name for the same functionality (case sensitive). Then you can use indirect tag bindings in your template and simply change the tag path you pass in to an instance of the template to indirectly bind all of the animations.

You can also reference custom properties in scripts so you could do this in scripts but it is better to do it with indirect tag bindings (performance and more intuitive).

Also, avoid using the "tag" expression. Instead, create custom properties and do indirect bindings on them to assign values. You'll get much better performance this way.

I hope that makes sense but I'm finding this a little difficult to explain. Key terms to search for in documentation:  
Indirect binding  
Template  
UDT

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 19, 2024, 5:51pm UTC](https://forum.inductiveautomation.com/t/functions-for-background/89131/3 "2024-04-19T17:51:55Z")

</div>

Also: Style Customizer

---

<div class="post-metadata">

**Author:** ![Alfredo\_Egmo](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Alfredo\_Egmo](https://forum.inductiveautomation.com/u/Alfredo_Egmo)\
**Post date:** [April 19, 2024, 5:54pm UTC](https://forum.inductiveautomation.com/t/functions-for-background/89131/4 "2024-04-19T17:54:46Z")

</div>

thanks I will check both ways.

---

<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:** [April 19, 2024, 8:35pm UTC](https://forum.inductiveautomation.com/t/functions-for-background/89131/5 "2024-04-19T20:35:31Z")

</div>

> [@Alfredo\_Egmo](#):
>
> function is to be utilized by several controls on screen

Consider using an expression-driven Vision Client tag.

---

<div class="post-metadata">

**Author:** ![Alfredo\_Egmo](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Alfredo\_Egmo](https://forum.inductiveautomation.com/u/Alfredo_Egmo)\
**Post date:** [April 19, 2024, 8:47pm UTC](https://forum.inductiveautomation.com/t/functions-for-background/89131/6 "2024-04-19T20:47:23Z")

</div>

thank you
