# Writing to an OPC tag from Expression Tag, or Client/Gateway Events

**URL:** <https://forum.inductiveautomation.com/t/writing-to-an-opc-tag-from-expression-tag-or-client-gateway-events/51164>\
**Category:** Ignition\
**Created:** [September 20, 2021, 7:19pm UTC](https://forum.inductiveautomation.com/t/writing-to-an-opc-tag-from-expression-tag-or-client-gateway-events/51164 "2021-09-20T19:19:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [September 20, 2021, 7:19pm UTC](https://forum.inductiveautomation.com/t/writing-to-an-opc-tag-from-expression-tag-or-client-gateway-events/51164/1 "2021-09-20T19:19:49Z")

</div>

I want to be able to write to a boolean tag (an OPC tag) when the result of a boolean expression tag is true. How should I do that? I have a hard time understanding this. I went through different threads  
This is my expression tag:

```auto
if ({[~]model.value}=1177, 1,:
  0
)

```

I tried to use the solution suggested here:

> [@Expression Tag that Writes to OPC Address (PLC)](https://forum.inductiveautomation.com/t/expression-tag-that-writes-to-opc-address-plc/43614/12):
>
> Also, diffSetpoint is not defined, so you’ll need to either assign a value, or hard code a value diffSetpoint = 100 if newValue.getValue() \> diffSetpoint: or if newValue.getValue() \> 100: Edit: just thinking through this a bit. If the tag that is triggering this event is an expression tag which results in a bool value then your script can be simplified if you only want to write to the tag on a true value: if newValue.getValue(): system.tag.writeBlocking(['[default]\_Rkn031\_900\_/Atomiz…

if you only want to write to the tag on a true value:

```auto
if newValue.getValue():
    system.tag.writeBlocking(['[default]led.value'],[newValue.getValue()])

```

It did not work.

Note that:  
**I may have some instances that I have multiple true values in a row, so it is not going to be "true, false, true, false" instead the result of the expression tag is more of a "true, true, true, false" . not sure if I should use client tag change.**
