# How to track value changes/ pass values in multi state button

**URL:** <https://forum.inductiveautomation.com/t/how-to-track-value-changes-pass-values-in-multi-state-button/60502>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [June 8, 2022, 4:25pm UTC](https://forum.inductiveautomation.com/t/how-to-track-value-changes-pass-values-in-multi-state-button/60502 "2022-06-08T16:25:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aacans](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@aacans](https://forum.inductiveautomation.com/u/aacans)\
**Post date:** [June 8, 2022, 4:25pm UTC](https://forum.inductiveautomation.com/t/how-to-track-value-changes-pass-values-in-multi-state-button/60502/1 "2022-06-08T16:25:30Z")

</div>

Hi everyone. I’m new to ignition.

I have a multi state button, I’d like to show a message box stating that the current button is already active when the said button is pressed again. I was thinking of using tag event script with the previous and current value in the value changed but I have noticed that the value does not pass/change if the same button is pressed. What possible alternatives can I use so I can track the changes/action in the said multi state button?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 8, 2022, 5:44pm UTC](https://forum.inductiveautomation.com/t/how-to-track-value-changes-pass-values-in-multi-state-button/60502/2 "2022-06-08T17:44:05Z")

</div>

First off, a tag change script can’t open a message box in your Vision client since it is gateway-scoped without something like a message handler. I would skip a message box all together as I don’t see what it will accomplish. With correct styling on the component, you can tell which state you’re in.

Right Click multi-state button → Customizers → Multi-State Button Customizer or `ctrl + u`

If you really want to see when the button is pressed when already active, you would add a property change script. Right click the component, and select scripting. In the `propertyChange` event handler put

```auto
if event.propertyName == 'controlValue' and event.newValue == event.oldValue:
		print 'No state change'

```

It will print in the console under `Tools`

---

<div class="post-metadata">

**Author:** ![aacans](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@aacans](https://forum.inductiveautomation.com/u/aacans)\
**Post date:** [June 8, 2022, 7:54pm UTC](https://forum.inductiveautomation.com/t/how-to-track-value-changes-pass-values-in-multi-state-button/60502/3 "2022-06-08T19:54:03Z")

</div>

Thank you for the comment. I have tried writing the script on the property change of multi state button but there seems to be a problem (which I don’t know of) because it does not print in the console. Although, there was no error entering the script. May I know what other things should I check?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 8, 2022, 8:06pm UTC](https://forum.inductiveautomation.com/t/how-to-track-value-changes-pass-values-in-multi-state-button/60502/4 "2022-06-08T20:06:17Z")

</div>

Evidently, the multi-state button does not have an accurate `oldValue`. When I print out oldValue, it always comes back as `None`. The work around is to add a custom property to the component, I made one called `lastState` and used this script

```auto
if event.propertyName == 'controlValue':
	if event.source.lastState != event.newValue:
		event.source.lastState = event.newValue
	else:
		print 'State did not change'

```

---

<div class="post-metadata">

**Author:** ![aacans](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@aacans](https://forum.inductiveautomation.com/u/aacans)\
**Post date:** [June 8, 2022, 9:56pm UTC](https://forum.inductiveautomation.com/t/how-to-track-value-changes-pass-values-in-multi-state-button/60502/5 "2022-06-08T21:56:15Z")

</div>

I have replaced the print to system.gui.errorBox and voila! It worked!. Thank you so much for your help.
