# 2 State Toggle Button Conditions

**URL:** <https://forum.inductiveautomation.com/t/2-state-toggle-button-conditions/18264>\
**Category:** Ignition\
**Created:** [June 1, 2018, 6:58pm UTC](https://forum.inductiveautomation.com/t/2-state-toggle-button-conditions/18264 "2018-06-01T18:58:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lonegator](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lonegator](https://forum.inductiveautomation.com/u/lonegator)\
**Post date:** [June 1, 2018, 6:58pm UTC](https://forum.inductiveautomation.com/t/2-state-toggle-button-conditions/18264/1 "2018-06-01T18:58:07Z")

</div>

If I have a tag (toggle\_tag) tied to a 2 state toggle button to toggle it true/false, but have another tag (alarm\_tag) that when true should immediately set toggle\_tag to false and not allow it to be manually toggled back to true until alarm\_tag goes false, what is the best way to accomplish this thru the 2 state toggle tag’s properties?

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [June 1, 2018, 7:08pm UTC](https://forum.inductiveautomation.com/t/2-state-toggle-button-conditions/18264/2 "2018-06-01T19:08:55Z")

</div>

You could add a ValueChange event script to the alarm\_tag so that when it goes from False to True, you set toggle\_tag to False:

```auto
	if initialChange:
		return
		
	if previousValue.value == False and currentValue.value == True:
		system.tag.write("[.]toggle_tag", False)

```

In your 2-State Toggle button just bind the enable property to the inverse of the alarm\_tag value:

```auto
!{alarm_tag}

```

---

<div class="post-metadata">

**Author:** ![zacslade](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacslade/32/3587_2.png) [@zacslade](https://forum.inductiveautomation.com/u/zacslade)\
**Post date:** [June 4, 2018, 11:16pm UTC](https://forum.inductiveautomation.com/t/2-state-toggle-button-conditions/18264/3 "2018-06-04T23:16:47Z")

</div>

You could also bind the enabled property of the button to the alarm\_tag.

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [June 5, 2018, 4:41pm UTC](https://forum.inductiveautomation.com/t/2-state-toggle-button-conditions/18264/4 "2018-06-05T16:41:26Z")

</div>

That's the opposite of what @lonegator wants:

> not allow it to be manually toggled back to true until alarm\_tag goes false

And lacks this bit:

> but have another tag (alarm\_tag) that when true should immediately set toggle\_tag to false

---

<div class="post-metadata">

**Author:** ![zacslade](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacslade/32/3587_2.png) [@zacslade](https://forum.inductiveautomation.com/u/zacslade)\
**Post date:** [June 5, 2018, 6:14pm UTC](https://forum.inductiveautomation.com/t/2-state-toggle-button-conditions/18264/5 "2018-06-05T18:14:05Z")

</div>

Right, I didn’t notice that you had already mentioned binding the enabled property to the alarm\_tag. I intended for the reader to intuitively understand that I meant an expression binding to the inverse of the value of the alarm\_tag, because it’s easier to say “bind it to the alarm tag” than to say “bind it via expression tag to the inverse of the alarm tag”.

Anyway, my mistake.
