# I have an Expression tag that is a boolean tag I want to link that to an OPCUA tag but cant think how to do it

**URL:** <https://forum.inductiveautomation.com/t/i-have-an-expression-tag-that-is-a-boolean-tag-i-want-to-link-that-to-an-opcua-tag-but-cant-think-how-to-do-it/63133>\
**Category:** Ignition\
**Created:** [August 18, 2022, 6:53am UTC](https://forum.inductiveautomation.com/t/i-have-an-expression-tag-that-is-a-boolean-tag-i-want-to-link-that-to-an-opcua-tag-but-cant-think-how-to-do-it/63133 "2022-08-18T06:53:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![batman01793](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@batman01793](https://forum.inductiveautomation.com/u/batman01793)\
**Post date:** [August 18, 2022, 6:53am UTC](https://forum.inductiveautomation.com/t/i-have-an-expression-tag-that-is-a-boolean-tag-i-want-to-link-that-to-an-opcua-tag-but-cant-think-how-to-do-it/63133/1 "2022-08-18T06:53:50Z")

</div>

I have an expression tag that is a boolean - it looks at 3 states and returns a true or false (is component correct, is recipe loaded & has work order started - this then indicates if the process is valid to run.

I want to link this to my machine so that I can display (igintion work order not started etc) on the machines local HMI via a boolean flag at the PLC.

if I link the opcua to this tag - the expression side is lost as it becomes an opcuia tag not an expression tag.

I have also tried looking at using a reference tag - but again this can only be a reference tag and not an opcua tag…

im probably (as normal) missing something that is right in front of me, but after searching the forum, google and tiral and error I am at a loss and need to reach out for help again.

Thanks

Please see example of the expression within the expression tag below

```auto
{[.]DataVerification/ComponentCorrect} && {[.]DataVerification/RecipeExist} && {[.]DataVerification/WOStarted}

```

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [August 18, 2022, 7:01am UTC](https://forum.inductiveautomation.com/t/i-have-an-expression-tag-that-is-a-boolean-tag-i-want-to-link-that-to-an-opcua-tag-but-cant-think-how-to-do-it/63133/2 "2022-08-18T07:01:17Z")

</div>

You would need a change script on that tag to write the result to an OPC tag, which would in turn write it don’t to the PLC.

You might be able to construct something with a derived tag using a `runScript()` in its setter that sends something down using `system.opc.write*`.

That being said, I could also use the functionality of an expression tag writing somewhere else. Maybe log a feature request.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [August 18, 2022, 9:00am UTC](https://forum.inductiveautomation.com/t/i-have-an-expression-tag-that-is-a-boolean-tag-i-want-to-link-that-to-an-opcua-tag-but-cant-think-how-to-do-it/63133/3 "2022-08-18T09:00:44Z")

</div>

Maybe you can write to an opcua tag with a derived tag pointing to it ? You could then use the read and write expression fields of the derived tag to add some logic to it.

warning: No idea if that’s actually possible, or if it’s a good solution.

---

<div class="post-metadata">

**Author:** ![IgnitionNewbie](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IgnitionNewbie](https://forum.inductiveautomation.com/u/IgnitionNewbie)\
**Post date:** [August 18, 2022, 10:49am UTC](https://forum.inductiveautomation.com/t/i-have-an-expression-tag-that-is-a-boolean-tag-i-want-to-link-that-to-an-opcua-tag-but-cant-think-how-to-do-it/63133/4 "2022-08-18T10:49:52Z")

</div>

I vaguely remember writing the value of an opc tag to a different opc tag with an expression tag… I had to make a script in here that would use the current value from the expression , this box should be in your expression

 ![TagEvent](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/8/b88112803e8493bf4d090e1ad47d0248150f9754.jpeg)

 ![currentvalue](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/e/4eda6f1bb81c36f7f2292f37a7d8e121e3d50029.jpeg)

then I used this underlined value and wrote that to the opc tag , which in your case would be the true and false part of the expression I believe

[system.tag.writeBlocking - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/system.tag.writeBlocking) the script had one of these in it so it would send the currentvalue of the expression to the other tag

[system.opc.writeValues - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/system.opc.writeValues) but there is also this, I didnt try this one but its the same effect

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 18, 2022, 11:38am UTC](https://forum.inductiveautomation.com/t/i-have-an-expression-tag-that-is-a-boolean-tag-i-want-to-link-that-to-an-opcua-tag-but-cant-think-how-to-do-it/63133/5 "2022-08-18T11:38:40Z")

</div>

I’d go the tag change event script route if you really want to use Ignition. Or can you replicate the same logic in the hmi?

But I’m curious if you couldn’t just add this into the plc itself? This would be the most logical place for it.

In a tag change event, you can use relative referencing to point to the OPC tag for example

```auto
system.tag.writeBlocking('[.]opcTagName', currentValue) 

```

---

<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:43pm UTC](https://forum.inductiveautomation.com/t/i-have-an-expression-tag-that-is-a-boolean-tag-i-want-to-link-that-to-an-opcua-tag-but-cant-think-how-to-do-it/63133/6 "2022-08-18T12:43:05Z")

</div>

> [@IgnitionNewbie](#):
>
> I vaguely remember writing the value of an opc tag to a different opc tag with an expression tag

v7.9 natively supported this. It was dropped in v8, but gateway upgrades would convert those into a legacy tag change event.

I recommend putting all such regular computations into a gateway timer event script that uses `writeBlocking` to set all the results into OPC tags (and memory tags). Such a script can skip writes to unchanged tags for efficiency.
