# Setting multiple tag values when a button is pressed

**URL:** <https://forum.inductiveautomation.com/t/setting-multiple-tag-values-when-a-button-is-pressed/63106>\
**Category:** Ignition\
**Tags:** ignition81, vision, scripting\
**Created:** [August 17, 2022, 5:04pm UTC](https://forum.inductiveautomation.com/t/setting-multiple-tag-values-when-a-button-is-pressed/63106 "2022-08-17T17:04:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![IvanP](https://avatars.discourse-cdn.com/v4/letter/i/74df32/32.png) [@IvanP](https://forum.inductiveautomation.com/u/IvanP)\
**Post date:** [August 17, 2022, 5:04pm UTC](https://forum.inductiveautomation.com/t/setting-multiple-tag-values-when-a-button-is-pressed/63106/1 "2022-08-17T17:04:09Z")

</div>

Hello,

I am trying to set multiple tag values when a button is pressed in vision. I’m having trouble with my script running and couldn’t find any examples to reference. I appreciate any pointers

```auto
paths = ["event.source.parent.ForceOpen", "event.source.parent.ForceClosed"]
values = [1, 0]
system.tag.writeAll(paths, values)

```

ForceOpen and ForceClosed are custom properties I created.

 ![Script](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/0/908085bf06557341446040a5718d1c44664c4ab9.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 17, 2022, 5:22pm UTC](https://forum.inductiveautomation.com/t/setting-multiple-tag-values-when-a-button-is-pressed/63106/2 "2022-08-17T17:22:29Z")

</div>

Custom properties are not tags so I doubt that you can use `system.tag.writAll()` to alter them.  
Try:

```auto
event.source.parent.ForceOpen = 1
event.source.parent.ForceClosed = 0

```

---

<div class="post-metadata">

**Author:** ![IvanP](https://avatars.discourse-cdn.com/v4/letter/i/74df32/32.png) [@IvanP](https://forum.inductiveautomation.com/u/IvanP)\
**Post date:** [August 18, 2022, 12:34pm UTC](https://forum.inductiveautomation.com/t/setting-multiple-tag-values-when-a-button-is-pressed/63106/3 "2022-08-18T12:34:17Z")

</div>

Thanks for your reply. I tried the code suggested and it does change the state for the ForceClosed and ForcedOpen tags in the template properties but it doesn’t change the state for the actual tags shown in the tag browser. I created an additional pop up window where I used the code below and that worked perfectly, however, a template would be easier to maintain rather than dozens of individual popup windows. Does anything stand out for what I’m doing wrong? Or is there a better way to do this?

 ![PopupTemplate](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/09ad7645b41a88f858ce2113d5fd745fd6da52c2.png)

Code that worked for individual windows.  
Force Open:

```auto
system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force On"], [1])
system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force Off"], [0])

```

Forced Closed:

```auto
system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force On"], [0])
system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force Off"], [1])

```

Auto:

```auto
system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force On"], [0])
system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force Off"], [0])

```

Code I tried for template that I’m trying to get to work.  
Force Open:

```auto
event.source.parent.ForceOpen = 1
event.source.parent.ForceClosed = 0

```

Forced Closed:

```auto
event.source.parent.ForceOpen = 0
event.source.parent.ForceClosed = 1

```

Auto:

```auto
event.source.parent.ForceOpen = 0
event.source.parent.ForceClosed = 0

```

---

<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 18, 2022, 12:42pm UTC](https://forum.inductiveautomation.com/t/setting-multiple-tag-values-when-a-button-is-pressed/63106/4 "2022-08-18T12:42:17Z")

</div>

Are the bindings on the custom properties set to bi-directional?

---

<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 18, 2022, 12:42pm UTC](https://forum.inductiveautomation.com/t/setting-multiple-tag-values-when-a-button-is-pressed/63106/5 "2022-08-18T12:42:26Z")

</div>

> [@IvanP](#):
>
> .. but it doesn't change the state for the actual tags shown in the tag browser.

Make sure the bindings are set for bidirectional.

---

<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:** [August 18, 2022, 12:47pm UTC](https://forum.inductiveautomation.com/t/setting-multiple-tag-values-when-a-button-is-pressed/63106/6 "2022-08-18T12:47:00Z")

</div>

Also, don’t make two calls to `writeBlocking` back-to-back–put both tags in one call. That’s why the args to it are lists.
