# Best way to handle an opc tag that writes as a bool and comes back as string?

**URL:** <https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [December 21, 2020, 9:01pm UTC](https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705 "2020-12-21T21:01:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmahaffey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tmahaffey/32/30949_2.png) [@tmahaffey](https://forum.inductiveautomation.com/u/tmahaffey)\
**Post date:** [December 21, 2020, 9:01pm UTC](https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705/1 "2020-12-21T21:01:34Z")

</div>

I think the title says it all. Any advice?

---

<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:** [December 22, 2020, 12:20am UTC](https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705/2 "2020-12-22T00:20:22Z")

</div>

Your title really doesn’t say it all. Handle it how?

---

<div class="post-metadata">

**Author:** ![tmahaffey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tmahaffey/32/30949_2.png) [@tmahaffey](https://forum.inductiveautomation.com/u/tmahaffey)\
**Post date:** [December 29, 2020, 3:22am UTC](https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705/3 "2020-12-29T03:22:06Z")

</div>

My problem is this tag is acting as two separate datatypes!

The tag needs to be defined as a boolean datatype to write a 1 to the opc tag, but after I write a 1 to it, since the same tag then comes back as a string message, it would have to then be defined as a string. Does that clear up my question?

---

<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:** [December 29, 2020, 3:58am UTC](https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705/4 "2020-12-29T03:58:58Z")

</div>

Where are you using this tag? Geez, give some real details.

---

<div class="post-metadata">

**Author:** ![tmahaffey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tmahaffey/32/30949_2.png) [@tmahaffey](https://forum.inductiveautomation.com/u/tmahaffey)\
**Post date:** [December 30, 2020, 7:00pm UTC](https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705/5 "2020-12-30T19:00:09Z")

</div>

In the designer.

---

<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:** [December 30, 2020, 7:03pm UTC](https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705/6 "2020-12-30T19:03:18Z")

</div>

Dude. Show your code. Show your tag configuration. Show your UI or however you are triggering the write. So far, you have provide _ **zero** _ information that would allow us to help you. ):

---

<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:** [December 30, 2020, 7:24pm UTC](https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705/7 "2020-12-30T19:24:58Z")

</div>

What device are you talking to? And what data type is the tag in the device itself? It sounds like the raw data type in the end device is a string, so why are you reading it into ignition as a bool? Can you not write “1” to it? In which case, if it truly is meant to be a bool, why is it _not_ a bool in the end device?

---

<div class="post-metadata">

**Author:** ![tmahaffey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tmahaffey/32/30949_2.png) [@tmahaffey](https://forum.inductiveautomation.com/u/tmahaffey)\
**Post date:** [December 30, 2020, 7:37pm UTC](https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705/8 "2020-12-30T19:37:45Z")

</div>

Here’s the tag configuraiton:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/748724909d577b0029a3025d586fcffe1fcb1c8f.png)

Here’s what I’m using in the tag browser:  
Before I write

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/06677ef03621c546ce230da7abd5505220f8535b.png)  
During write  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/5/25efa7b858fda598bb1908e55e295351ac8aae01.png)  
Reading after I write  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/f/6f4c58a672397e2bd35b1b20310b4bf6931a8a5b.png)

Info on the device/driver:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/9/59f7aea0cc3bfd2e2a647aa38413aaa7e2942265.png)

[https://autosoln.atlassian.net/wiki/spaces/ACMDOCS/pages/215842828/ROC+Commands](https://autosoln.atlassian.net/wiki/spaces/ACMDOCS/pages/215842828/ROC+Commands)

Thanks a bunch

---

<div class="post-metadata">

**Author:** ![BenKearney](https://avatars.discourse-cdn.com/v4/letter/b/b19c9b/32.png) [@BenKearney](https://forum.inductiveautomation.com/u/BenKearney)\
**Post date:** [December 30, 2020, 7:58pm UTC](https://forum.inductiveautomation.com/t/best-way-to-handle-an-opc-tag-that-writes-as-a-bool-and-comes-back-as-string/41705/9 "2020-12-30T19:58:59Z")

</div>

That link is to a boolean-driven command, which would usually result in the remote system doing something when you pulse that tag, then presenting the results on a different tag, not on the same tag replacing your boolean value.

You probably need to talk to the developer of that software and ask them to explain what should happen when you write a true to that tag. I’m guessing it updates this one:

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

[https://autosoln.atlassian.net/wiki/spaces/ACMDOCS/pages/215875607/ROC+OPC+Items](https://autosoln.atlassian.net/wiki/spaces/ACMDOCS/pages/215875607/ROC+OPC+Items)
