# How can I toggle a Boolean tag when String changes in the Text Field?

**URL:** <https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315>\
**Category:** Ignition\
**Tags:** ignition81, scripting, vision\
**Created:** [August 2, 2023, 8:46pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315 "2023-08-02T20:46:17Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shirshak\_Chhetri](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Shirshak\_Chhetri](https://forum.inductiveautomation.com/u/Shirshak_Chhetri)\
**Post date:** [August 2, 2023, 8:46pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/1 "2023-08-02T20:46:17Z")

</div>

Hello, I have been trying to get the value of a Boolean Tag to turn on momentarily when String changes in the text field. I have tried out couple scripts on property change handler of the Text Field but none seem to work. Any help is appreciated.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/2/6298f7d00af17e8897d9a98056621b519b555520.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 2, 2023, 8:50pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/2 "2023-08-02T20:50:32Z")

</div>

What is the real problem you are trying to solve? There may be a much better way to achieve your goal.  
What action is the boolean tag going to trigger?

---

<div class="post-metadata">

**Author:** ![Shirshak\_Chhetri](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Shirshak\_Chhetri](https://forum.inductiveautomation.com/u/Shirshak_Chhetri)\
**Post date:** [August 2, 2023, 8:54pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/3 "2023-08-02T20:54:25Z")

</div>

What I'm trying to achieve is, everytime the string in Partname updates, I want to energize a reset tag on the PLC.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 2, 2023, 8:55pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/4 "2023-08-02T20:55:29Z")

</div>

Why not do that in the PLC? It would be much more reliable.

---

<div class="post-metadata">

**Author:** ![Shirshak\_Chhetri](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Shirshak\_Chhetri](https://forum.inductiveautomation.com/u/Shirshak_Chhetri)\
**Post date:** [August 2, 2023, 9:01pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/5 "2023-08-02T21:01:55Z")

</div>

It would be more reliable to get it done in PLC but I don't have much PLC experience. How would I look for changes in the String's tag through PLC.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 2, 2023, 9:08pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/6 "2023-08-02T21:08:02Z")

</div>

That depends on where the string is coming from. Does the PLC have the string value in memory?

If it does then,

- Compare `PartName` with `prevPartName`.
- If changed then turn on `Reset OneShot` in the PLC. Use that to reset whatever has to be reset.
- Set `prevPartName = PartName`.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 2, 2023, 9:12pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/7 "2023-08-02T21:12:47Z")

</div>

What type of PLC?

---

<div class="post-metadata">

**Author:** ![Shirshak\_Chhetri](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Shirshak\_Chhetri](https://forum.inductiveautomation.com/u/Shirshak_Chhetri)\
**Post date:** [August 2, 2023, 9:15pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/8 "2023-08-02T21:15:09Z")

</div>

Its an AB compactLogix 1769.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 2, 2023, 9:23pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/9 "2023-08-02T21:23:18Z")

</div>

Assuming that you have a String type tag that is storing this information then you would just compare for a change in the value using a NEQ and then MOV the current value into a LastValue Tag.

Copy and paste this into a rung, and replace the tag names with the relevant references.

```auto
 NEQ LastPartName PartName BST OTE PartNameChange NXB MOV PartName LastPartName BND

```

This will turn on the PartNameChange Bit for 1 scan, if you need it on longer than that you can utilize an OTL, OTU, and TON to reset the bit after some delay.

---

<div class="post-metadata">

**Author:** ![Shirshak\_Chhetri](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Shirshak\_Chhetri](https://forum.inductiveautomation.com/u/Shirshak_Chhetri)\
**Post date:** [August 2, 2023, 9:41pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/10 "2023-08-02T21:41:00Z")

</div>

OK, but what are the BST, NXB and BND operations?

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [August 2, 2023, 9:45pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/11 "2023-08-02T21:45:10Z")

</div>

Here is an example where the name change will set the bool. You can reset the bool with a button. It just uses a property change script.

If you want the bool to auto reset after a period of time, that is possible, but I didn't show that in the attached example.

To test make sure to put in preview mode.

[PartName.zip](https://forum.inductiveautomation.com/uploads/short-url/nAVZBV4ZtZOZjBw0cLflzFGVk7C.zip) (2.8 KB)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 2, 2023, 9:46pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/12 "2023-08-02T21:46:18Z")

</div>

> [@Shirshak\_Chhetri](#):
>
> OK, but what are the BST, NXB and BND operations?

They're the branch instructions and will be explained in the Logix5000 / Studio5000 help files. When you paste in the code it will be converted to ladder logic and the meaning should be obvious.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 2, 2023, 9:54pm UTC](https://forum.inductiveautomation.com/t/how-can-i-toggle-a-boolean-tag-when-string-changes-in-the-text-field/77315/13 "2023-08-02T21:54:41Z")

</div>

As @transistor said, those create a branch on the rung.

BST = Branch Start (instructions following this will be on the top rung)  
NXB = Next Branch (Add one at the start of each new branch)  
BND = Branch End

It will look basically like this:

```plaintext
|--NEQ------------------------+------------OTE----+--|
| |------------MOV----|

```
