# Dynamic Background Binding based on Limits

**URL:** <https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047>\
**Category:** Ignition\
**Created:** [July 31, 2019, 3:51pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047 "2019-07-31T15:51:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 3:51pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/1 "2019-07-31T15:51:54Z")

</div>

I have been searching for examples of binding the background color of a field to limit values.  
Have not had any luck.

I am trying to establish color(?,?,?) based on

If (PV \< H\_Level Then color (WHITE)  
If (PV \> H\_Level) && (PV \< HH\_Level) Then color(ORANGE)  
Else If (PV \> HH\_Level) Then color (RED)…

Seems like it should be straight forward but I am getting nowhere…

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 31, 2019, 3:52pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/2 "2019-07-31T15:52:53Z")

</div>

What version of Ignition are you using?

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 4:12pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/3 "2019-07-31T16:12:22Z")

</div>

8.0

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 4:18pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/4 "2019-07-31T16:18:54Z")

</div>

8.0.2 to be exact

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 4:22pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/5 "2019-07-31T16:22:37Z")

</div>

I have to run to a production issue.  
I’ll check back later…

Thanks in Advance…

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 5:04pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/6 "2019-07-31T17:04:57Z")

</div>

Im back

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 5:46pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/7 "2019-07-31T17:46:18Z")

</div>

Any ideas?

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [July 31, 2019, 5:58pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/8 "2019-07-31T17:58:42Z")

</div>

Could you provide more information regarding your script; where does this script reside? Are you trying to conditionally change the background via an expression binding or a script?

Assuming you're writing the script in an expression binding have a look at these pages in the help manual.  
expression if statement: [if - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/if)  
expression toColor(): [toColor - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/toColor)

you're syntax:

> (PV \< H\_Level Then color (WHITE)  
> If (PV \> H\_Level) && (PV \< HH\_Level) Then color(ORANGE)  
> Else If (PV \> HH\_Level) Then color (RED)…

transforms into:

```auto
if (PV < H_Level, // first if condition
	"white", // true
	if (PV > H_Level && PV < HH_Level, // else if
		"orange", // true
		if( PV > HH_Level, // else if
			"red", // true
			"gray" // else
		)
	)
)

```

Keep in mind you'll need to point your conditionals (PV, H\_Level, HH\_Level) to tags or properties.  
Cheers.

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 6:01pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/9 "2019-07-31T18:01:02Z")

</div>

Yes. I was looking to do this in the background binding of a numerical display field…

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 31, 2019, 6:01pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/10 "2019-07-31T18:01:41Z")

</div>

`if({pv} < {H_Level}, color(255,255,255), if({pv} < {HH_Level}, color(255,153,51), color(255,0,0)))`  
(pseudo-code - please provide the correct interpolation assignments)  
as an expression in Vision. If you’re using Perspective, I can provide a mapping solution, but I have a meeting so it will be a bit before I can do so.

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 6:11pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/11 "2019-07-31T18:11:35Z")

</div>

Thanks Ill give this a go.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 31, 2019, 6:38pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/12 "2019-07-31T18:38:08Z")

</div>

The following screenshot is a Perspective binding with transforms which would do what you want without needing to create the colors from expressions.

 ![21%20AM](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/065c6afe8fc4950799c3d5f501fab2c8325114af.png)

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 7:58pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/13 "2019-07-31T19:58:07Z")

</div>

OK. That would be a cleaner method.  
It’s the syntax that is new to me.

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 8:12pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/14 "2019-07-31T20:12:10Z")

</div>

I am not sure but I think there is an issue because this in in a UDT

IF ({Report\_Static.SILO\_ID::AMOUNT} \< {Report\_Static.SILO\_ID::H\_Warn}),0  
IF ({Report\_Static.SILO\_ID::AMOUNT} \> {Report\_Static.SILO\_ID::H\_Warn} &&  
({Report\_Static.SILO\_ID::AMOUNT} \< {Report\_Static.SILO\_ID::HH\_Alarm})1  
IF ({Report\_Static.SILO\_ID::AMOUNT} \> {Report\_Static.SILO\_ID::HH\_Alarm},2

Does not compile…

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [July 31, 2019, 8:13pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/15 "2019-07-31T20:13:30Z")

</div>

IF ({Report\_Static.SILO\_ID::AMOUNT} \< {Report\_Static.SILO\_ID::H\_Warn}),0  
IF ({Report\_Static.SILO\_ID::AMOUNT} \> {Report\_Static.SILO\_ID::H\_Warn} &&  
({Report\_Static.SILO\_ID::AMOUNT} \< {Report\_Static.SILO\_ID::HH\_Alarm}),1  
IF ({Report\_Static.SILO\_ID::AMOUNT} \> {Report\_Static.SILO\_ID::HH\_Alarm},2

Actually

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 31, 2019, 8:15pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/16 "2019-07-31T20:15:30Z")

</div>

Perhaps because you’re missing the closing parentheses? Could you make sure you’ve copied the entire expression function, then paste it between triple ticks? “```your code here```”  
Also, you’re missing commas after values.  
Also also, the final expression requires three arguments and you’ve only supplied two.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 31, 2019, 8:19pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/17 "2019-07-31T20:19:48Z")

</div>

```auto
IF ({Report_Static.SILO_ID::AMOUNT} < {Report_Static.SILO_ID::H_Warn},0,
IF ({Report_Static.SILO_ID::AMOUNT} > {Report_Static.SILO_ID::H_Warn} &&
{Report_Static.SILO_ID::AMOUNT} < {Report_Static.SILO_ID::HH_Alarm},1,
IF ({Report_Static.SILO_ID::AMOUNT} > {Report_Static.SILO_ID::HH_Alarm},2, 3)))

```

Evaluates for me. I added closing parentheses to the end, I removed unnecessary parentheses, I added commas, and I added a final argument to the final expression.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 31, 2019, 8:25pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/18 "2019-07-31T20:25:27Z")

</div>

Also, you should be careful because you’re excluding instances where `{Report_Static.SILO_ID::AMOUNT}` is EQUAL TO your `H_XXXXX` values.

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [August 13, 2019, 5:18pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/19 "2019-08-13T17:18:06Z")

</div>

Ignition 8.0.3 does not seem to have access to add the relationship for the binding transforms for the background color of a numerical label. Was away on a commissioning so still working through this background color change issue

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 13, 2019, 5:46pm UTC](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047/20 "2019-08-13T17:46:54Z")

</div>

Transforms are available in Perspective, not Vision, so you would not have the Mapping transform available to you, and would need to supply the color values within the expression, instead of supplying numeric values which would be transformed by the Mapping transform into colors.

```auto
IF ({Report_Static.SILO_ID::AMOUNT} < {Report_Static.SILO_ID::H_Warn}, <good_color_here>,
IF ({Report_Static.SILO_ID::AMOUNT} > {Report_Static.SILO_ID::H_Warn} &&
{Report_Static.SILO_ID::AMOUNT} < {Report_Static.SILO_ID::HH_Alarm},<warning_color_here>,
IF ({Report_Static.SILO_ID::AMOUNT} > {Report_Static.SILO_ID::HH_Alarm},<critical_color_here>, <fallback_color_here>)))

```

[Next page](https://forum.inductiveautomation.com/t/dynamic-background-binding-based-on-limits/27047.md?page=2)
