# Changing Component Background with Script

**URL:** <https://forum.inductiveautomation.com/t/changing-component-background-with-script/23204>\
**Category:** Ignition\
**Created:** [March 10, 2019, 11:13pm UTC](https://forum.inductiveautomation.com/t/changing-component-background-with-script/23204 "2019-03-10T23:13:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [March 10, 2019, 11:13pm UTC](https://forum.inductiveautomation.com/t/changing-component-background-with-script/23204/1 "2019-03-10T23:13:06Z")

</div>

Hello:

I can’t get this to work and I don’t know what I’m doing wrong. (I get no errors, but does not change colors!)

‘’‘if “W1Flow” \> “W1Setpoint” :  
W1FPress = event.source  
W1FPress.background = system.gui.color(255,0,0)’’’

W1Flow is a Tag value(Float) and W1Setpoint is a Tag value(Float)

W1FPress is a numeric label - I have this script in the property change event of W1FPress

All I trying to do is if the value of W1Flow becomes larger then W1Setpoint change the background color of W1FPress to red.

Thanks

---

<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 11, 2019, 1:57am UTC](https://forum.inductiveautomation.com/t/changing-component-background-with-script/23204/2 "2019-03-11T01:57:00Z")

</div>

Just putting tag names in quotes doesn’t give you their value. You are just comparing those two strings lexically. You need to use system.tag.read() to retrieve a tag value in scripting. Or bind those tags to custom properties of W1FPress and refer to them that way. In either case, a propertyChange script is wrong if it doesn’t include checking for the appropriate event.propertyName.

---

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [March 11, 2019, 2:08am UTC](https://forum.inductiveautomation.com/t/changing-component-background-with-script/23204/3 "2019-03-11T02:08:52Z")

</div>

Thanks, I understand - it is now working.
