# Creating a button to be disabled based on a bool value?

**URL:** <https://forum.inductiveautomation.com/t/creating-a-button-to-be-disabled-based-on-a-bool-value/104894>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [April 9, 2025, 2:08pm UTC](https://forum.inductiveautomation.com/t/creating-a-button-to-be-disabled-based-on-a-bool-value/104894 "2025-04-09T14:08:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergio\_valencia](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sergio\_valencia](https://forum.inductiveautomation.com/u/sergio_valencia)\
**Post date:** [April 9, 2025, 2:08pm UTC](https://forum.inductiveautomation.com/t/creating-a-button-to-be-disabled-based-on-a-bool-value/104894/1 "2025-04-09T14:08:46Z")

</div>

This button is to a Pop Up Window. I would like for this to be disabled if a bool value = 0 and enabled if that same bool value = 1  
The problem is the button always enables the Pop Up Window no matter the bools status.... I have the Enabled expression for that button written as so....

`{[default]AZ ASRS Conveyor System/Wave Control/C7-1 BB1001A/N701:13_2.value}= "1"`

---

<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:** [April 9, 2025, 2:14pm UTC](https://forum.inductiveautomation.com/t/creating-a-button-to-be-disabled-based-on-a-bool-value/104894/2 "2025-04-09T14:14:55Z")

</div>

Don't use an expression binding at all. Bind the enabled property **directly** to the tag in question.  
The binding will automatically coerce 0 as false, and any other number as true; if your tag is essentially a boolean but has an integer data type, that should give you the behavior you want.

If you _do_ want to do it with an expression (you shouldn't - it's slower, for zero gain), you need to be sure your data types match.

`{[default]AZ ASRS Conveyor System/Wave Control/C7-1 BB1001A/N701:13_2.value}= "1"`  
Is comparing a tag value that is presumably an **integer** with a **string** (`"1"`).  
Even if the string contains only a single numeric digit, neither our expression language nor Python will do any automatic coercion from string to number or vice versa; [that way lies madness](https://www.destroyallsoftware.com/talks/wat).

What would _probably_ work (again, I'm just assuming your tag is actually an integer):  
`{[default]AZ ASRS Conveyor System/Wave Control/C7-1 BB1001A/N701:13_2} = 1`

---

<div class="post-metadata">

**Author:** ![sergio\_valencia](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sergio\_valencia](https://forum.inductiveautomation.com/u/sergio_valencia)\
**Post date:** [April 9, 2025, 2:36pm UTC](https://forum.inductiveautomation.com/t/creating-a-button-to-be-disabled-based-on-a-bool-value/104894/3 "2025-04-09T14:36:06Z")

</div>

I bind the enabled property to the tag directly and the POP UP WINDOW still enables no matter the tag status. I may be missing something very basic.....

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/8/18a06c9044fc243fbd703a611380c57646c33b6a.png)

---

<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 9, 2025, 2:57pm UTC](https://forum.inductiveautomation.com/t/creating-a-button-to-be-disabled-based-on-a-bool-value/104894/4 "2025-04-09T14:57:27Z")

</div>

Also, make sure you are using the "actionPerformed" event of the button. The other events, like mouse clicks, do not honor the enable/disable status.

---

<div class="post-metadata">

**Author:** ![sergio\_valencia](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sergio\_valencia](https://forum.inductiveautomation.com/u/sergio_valencia)\
**Post date:** [April 9, 2025, 3:36pm UTC](https://forum.inductiveautomation.com/t/creating-a-button-to-be-disabled-based-on-a-bool-value/104894/5 "2025-04-09T15:36:50Z")

</div>

YES!! That's what was missed!! Awesome TY!!

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [April 9, 2025, 3:59pm UTC](https://forum.inductiveautomation.com/t/creating-a-button-to-be-disabled-based-on-a-bool-value/104894/6 "2025-04-09T15:59:17Z")

</div>

I saw the blue text on 'that way lies madness' and immediately knew "this is going to be a JS link, and I hope it's Wat" and was not disappointed
