# Issues writing to tag boolean value

**URL:** <https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [March 27, 2023, 3:00pm UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645 "2023-03-27T15:00:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martyn\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martyn\_Smith](https://forum.inductiveautomation.com/u/Martyn_Smith)\
**Post date:** [March 27, 2023, 3:00pm UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/1 "2023-03-27T15:00:13Z")

</div>

I have button which triggers an event on double click.

Essentially, I am reading the tag for its True/False Value. So far so good using:-  
`tagLineRead = system.tag.readBlocking([self.view.params.TagLineRead])[0].value`

I am basically toggling the value... so I flip it...  
`tagLineWrite = not tagLineRead # False is now True... or True is now False`

However, when I try to write the value... nothing is happening. I have tried replacing True/False with 1/0 respectively and, again.. nothing.

This is the code I am using:-

```auto
writePaths = [self.view.params.TagLineWrite]
writeValues = [tagLineWrite]
system.tag.writeBlocking(writePaths, writeValues)

```

I created a popup so I can confirm the tagLineRead is a boolean, and that tagLineWrite is correctly set to the opposite value.

I also wrapped the code around a Try-Except... and there is no exception error (which would have created a popup)

I can only assume the issue is related to sending to boolean tags ????

All examples I see for writeBlocking send text and numbers.. but not boolean.

I came across similar queries but does not solve my problem--

> [@Write Boolean Tag Error](https://forum.inductiveautomation.com/t/write-boolean-tag-error/62262):
>
> I’d like to write bool tag by gateway event but sometimes it gives error as below. I have no idea why the error occurred randomly? It sometimes works but sometimes error occurs. Ignition Version: 8.1.13 Gateway Event Script , Three methods were used. The issue can’t be resolved. system.tag.write(basePath + "/Test", 0) system.tag.writeAsync([basePath + '/Test'], [0]) system.tag.writeBlocking(basePath + "/Test", 0) Error Message ,when I use the function =\> system.tag.writeBlocking(basePath + “…

The tag I am using to write to -- looks fine. Others have verified this also in team. If I can attach screen shots, I will be happy to provide anything (on request)

If I can be any further help with this query -- please let me know.

Thanks.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 27, 2023, 3:18pm UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/2 "2023-03-27T15:18:33Z")

</div>

Could you supply the full code of the onDoubleClick Event so that we can verify there are no other potential issues preventing the latter code from executing?

Have you already checked your Gateway logs to verify the code is not encountering an issue when executed?

Could you provide a screenshot of the actual Event configuration dialog? I'd like to verify you have this in the onDoubleClick Event, and not on the Click event, which would just be cancelling itself out when performing a double-click.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [March 27, 2023, 3:22pm UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/3 "2023-03-27T15:22:06Z")

</div>

> [@Martyn\_Smith](#):
>
> ```auto
> writePaths = [self.view.params.TagLineWrite]
> writeValues = [tagLineWrite]
> system.tag.writeBlocking(writePaths, writeValues)
> 
> ```

`self.view.params.TagLineRead` and `self.view.params.TagLineWrite` are not tag paths?? So, if these properties are tag bindings, there is no need to tag read and write. Make the bindings bi-directional and you can just set the property to update the tag source.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 27, 2023, 3:28pm UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/4 "2023-03-27T15:28:48Z")

</div>

I just tried this with the following code and it worked as expected:

```auto
    tagPath = "[default]Experimentation/New Tag"
	tagLineRead = system.tag.readBlocking([tagPath])[0].value
	tagLineWrite = not tagLineRead
	system.tag.writeBlocking([tagPath], [tagLineWrite])

```

---

<div class="post-metadata">

**Author:** ![Martyn\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martyn\_Smith](https://forum.inductiveautomation.com/u/Martyn_Smith)\
**Post date:** [March 28, 2023, 9:59am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/5 "2023-03-28T09:59:28Z")

</div>

Thank you both for taking the time to respond.

(I could not 'At' you both, as it wouldn't allow me for being a new user)

It is appreciated. Please see my reply which should cover both your queries.

The...  
`self.view.param.TagLineRead`  
...and...  
`self.view.param.TagLineWrite`  
...are parameters I have created, as you can create them in a View (at least in perspective.. not sure about Vision)

I am making use of these to simplify my project. This view is being used in multiple places, each using different tags for reading and writing to.

It is best to see TagLineRead and TagLineWrite with these values:-

```auto
"[default]L1_to_4_Ignition_Read/L1_to_4_Ignition_Read_0_[0]"
"[default]L1_to_4_Ignition_WriteV1/L1_to_4_Ignition_WriteV1_0_[0]"

```

Also note there is another self.view.param I use which holds a tag that write integer values - and this is working. This is why I believe the issue _could_ related to boolean values.

I will be attaching a screenshot of the Event Configuration...  
I know the code on dbl click triggers because I included a popup view to help debug.  
Here is the double click code with additional comments. It is essentially the line-by-line in the original post.

```auto
def runAction(self, event):
	"""
	Method that will run whenever the selected event fires.
        ...Snipped... to shorten
	"""
	try:
		tagLineRead = system.tag.readBlocking([self.view.params.TagLineRead])[0].value
		tagLineWrite = not tagLineRead

                # The commented codes was used for popup debugging information
                # It was there to prove:-
                # 1) tagLineRead returned True or False from the tag (this worked)
                # 2) tagLineWrite will store the opposite value (this is ok)
                # 3) I cover what I am writing to - self.view.params.TagLineWrite, which in this case is..
                # "[default]L1_to_4_Ignition_WriteV1/L1_to_4_Ignition_WriteV1_0_[0]"

		#msg = "current value: " + str(tagLineRead) + ", new value: " + str(tagLineWrite) + " ...To Tag: " + self.view.params.TagLineWrite		
		#system.perspective.openPopup("specialid", "Popups/Alert", params = {'title': 'Change trigger', 'message': msg})

		writePaths = [self.view.params.TagLineWrite]
		writeValues = [tagLineWrite]
		system.tag.writeBlocking(writePaths, writeValues)
	except Exception as e:
		system.perspective.openPopup("specialid", "Popups/Alert", params = {'title': 'Error', 'message': str(e)})

```

---

<div class="post-metadata">

**Author:** ![Martyn\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martyn\_Smith](https://forum.inductiveautomation.com/u/Martyn_Smith)\
**Post date:** [March 28, 2023, 10:00am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/6 "2023-03-28T10:00:16Z")

</div>

Was this tested with boolean value?  
I can get this to work for Integer.

Thanks.

---

<div class="post-metadata">

**Author:** ![Martyn\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martyn\_Smith](https://forum.inductiveautomation.com/u/Martyn_Smith)\
**Post date:** [March 28, 2023, 10:04am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/7 "2023-03-28T10:04:50Z")

</div>

![event-config-dblclick](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/f/6fe8444e1a2a636cfe08719f36222a5e3f838af9.png)

---

<div class="post-metadata">

**Author:** ![Martyn\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martyn\_Smith](https://forum.inductiveautomation.com/u/Martyn_Smith)\
**Post date:** [March 28, 2023, 10:12am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/8 "2023-03-28T10:12:51Z")

</div>

I just edited my main reply and after 'Save and Close' (to fixing some mistakes) -- but it has disappeared. Very frustrated.  
I am hoping it will return.

---

<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:** [March 28, 2023, 10:17am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/9 "2023-03-28T10:17:10Z")

</div>

![Screenshot_20230328-204321](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/2431a5dbabe65a6f0242dfba68710b70d7fea768.jpeg)  
Unrelated, but before you get too far down the rabbit hole, I would strongly recommend you write a project function to handle opening this error popup. Calling that openPopup function everywhere will get old very quickly, and also mean you can't easily change it if you need to add additional functionality to it. Also, you can use

```auto
import traceback
traceback.format_exc()

```

to get the error info

---

<div class="post-metadata">

**Author:** ![Martyn\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martyn\_Smith](https://forum.inductiveautomation.com/u/Martyn_Smith)\
**Post date:** [March 28, 2023, 10:27am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/10 "2023-03-28T10:27:55Z")

</div>

Hi and thank you for the tip.

This popup was purely created to help aid/resolve this problem. Once sorted and back on track I will be handling these types of things much better.

The idea of of a project function and using traceback has been noted. Thank 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:** [March 28, 2023, 10:42am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/11 "2023-03-28T10:42:27Z")

</div>

Where are you testing in? The designer? Do you have gateway write option enabled?

---

<div class="post-metadata">

**Author:** ![Martyn\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martyn\_Smith](https://forum.inductiveautomation.com/u/Martyn_Smith)\
**Post date:** [March 28, 2023, 10:52am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/12 "2023-03-28T10:52:00Z")

</div>

I am using the designer. There is a Play button but I am mostly doing "Tools-\>Launch Perspective-\>Launch Session" for testing. I save changes beforehand.

As for Gateway Write Open -- I am not familiar with this.

My first reply has been hidden (I edited it to correct something) -- which is under review. Kinda repeating what is in that reply...

One thing to note... I can get writeBlocking to work for integer values. There is another tag I use to send a number, and this is working. It just doesn't work for boolean. I am bringing this up because I don't know if this means that Gateway Write is enabled.

Cheers

---

<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:** [March 28, 2023, 10:57am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/13 "2023-03-28T10:57:07Z")

</div>

Ok, if you can write other values then the option is set to read/write. It's in the top left in the toolbar. 3 icons: no comms, read only, and read write

What is the result from the write function? Just wrap the write call inside system.perspective.print  
A failed write is not an exception, and you have to catch these using the return value from the write

---

<div class="post-metadata">

**Author:** ![Martyn\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martyn\_Smith](https://forum.inductiveautomation.com/u/Martyn_Smith)\
**Post date:** [March 28, 2023, 11:55am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/14 "2023-03-28T11:55:18Z")

</div>

Again -- thanks for helping.

I have updated to code to get the response from writeBlocking, send dumped in perspective.print.

I am getting an error - but I need to speak to engineering on this. I will get back ASAP with any errors printed once I confirmed all other parts are fully operational.

---

<div class="post-metadata">

**Author:** ![Martyn\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martyn\_Smith](https://forum.inductiveautomation.com/u/Martyn_Smith)\
**Post date:** [April 4, 2023, 11:47am UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/15 "2023-04-04T11:47:54Z")

</div>

Hi -- update on the situation.

Apologies in the delay - I have just spoken with an engineer and, after tests, it appears it works when I setup a tag directly to an index.

I will provide screenshots to help with my (poor) explanation. Maybe the original way can still be done?

So.. a tag originally was created as a Boolean Array.  
When I try to tick the first index, or any of the indexes for that matter, it pops up this error:-  
_"Error writing to L1\_to\_4\_Ignition\_WriteV1\_0\_[0].value: Error\_Exception("Error writing to tag '[default]L1\_to\_4\_Ignition\_WriteV1/L1\_to\_4\_Ignition\_WriteV1\_0\_': null")"_  
 ![ticking_from_bool_array](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/f/df15b04f833a9c244bd415e74a486223087a80cd.png)

However, when I created a tag for the first index, it works when I toggle the value. SUCCESS  
 ![ticking_from_boolean_index0](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/36cc9ea9d07836cbe596bd39ed56574372219ca3.png)

So I have figured out how to "fix" the issue.  
The downside to this approach is I have to create a tag for each index (16 of them)

Can I still create a tag as a Boolean Array? This would make life easier. Perhaps we are doing something wrong. Maybe the screens will help with this.

Thanks.

---

<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:** [April 4, 2023, 12:06pm UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/16 "2023-04-04T12:06:12Z")

</div>

> [@Martyn\_Smith](#):
>
> Can I still create a tag as a Boolean Array?

No, not for that PLC. Whether an array is writable and/or writable by element is very dependent on PLC and driver support. Your test showed it wasn't supported.

---

<div class="post-metadata">

**Author:** ![Martyn\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martyn\_Smith](https://forum.inductiveautomation.com/u/Martyn_Smith)\
**Post date:** [April 4, 2023, 12:12pm UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/17 "2023-04-04T12:12:54Z")

</div>

That you all for taking the time to help me resolve the issue.

We got there in the end.

Overall, I was not doing anything wrong - generally - except trying to write to an index/element of a boolean array.

When I created a tag directly to index[0] - it worked.

Looks like I will have to create a tag for each index. Not the end of the world.

Again - thank you all.

---

<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:** [April 4, 2023, 8:48pm UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/18 "2023-04-04T20:48:40Z")

</div>

I wonder how writing to a boolean array appears in the audit log? This, tag security, and the potential complexity of pathing to the tags would be my biggest turn offs to using boolean arrays. Especially considering (from my understanding) that you're not gaining any efficiencies in comms by doing it that way instead of using multiple bool tags. I think it would also make pages with bindings to its bits update more frequently and unnecessarily due to the change of any of the bools in the array triggering change events on all of the bools (unless I'm misunderstanding them)

---

<div class="post-metadata">

**Author:** ![irawan.gunadi](https://avatars.discourse-cdn.com/v4/letter/i/aeb1de/32.png) [@irawan.gunadi](https://forum.inductiveautomation.com/u/irawan.gunadi)\
**Post date:** [September 27, 2024, 5:07pm UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/19 "2024-09-27T17:07:33Z")

</div>

Hello there, I am able to write boolean value to a Rockwell DINT via UDT. It keeps my expression/scripting more simple. Perhaps this approach can be useful for some folks.

 ![Rockwell DINT Ignition](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/f/df70be50e6c6aa1dfea72dca1f40c5be36b14daa.png)

---

<div class="post-metadata">

**Author:** ![Henrique\_Trebilcock](https://avatars.discourse-cdn.com/v4/letter/h/8edcca/32.png) [@Henrique\_Trebilcock](https://forum.inductiveautomation.com/u/Henrique_Trebilcock)\
**Post date:** [January 28, 2025, 5:00pm UTC](https://forum.inductiveautomation.com/t/issues-writing-to-tag-boolean-value/71645/20 "2025-01-28T17:00:07Z")

</div>

Thank you, it worked like a charm!
