# Write Value to Tag using Pushbutton Script

**URL:** <https://forum.inductiveautomation.com/t/write-value-to-tag-using-pushbutton-script/85311>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 6, 2024, 5:19pm UTC](https://forum.inductiveautomation.com/t/write-value-to-tag-using-pushbutton-script/85311 "2024-02-06T17:19:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ftuquabo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ftuquabo/32/29161_2.png) [@ftuquabo](https://forum.inductiveautomation.com/u/ftuquabo)\
**Post date:** [February 6, 2024, 5:19pm UTC](https://forum.inductiveautomation.com/t/write-value-to-tag-using-pushbutton-script/85311/1 "2024-02-06T17:19:10Z")

</div>

I'm pretty new to ignition.

Looking to use an onClick event to write a value to a tag using a push button. Does the script below look correct or is there something that i'm missing. Thanks in Advance!

def runAction(self, event):

```
										 params = {
												 'deviceTagPath':[RiversideWTPProvider]HighService/HSP No1 Check Valve/OPEN,
												 'valueToWrite':1,}

```

---

<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:** [February 6, 2024, 5:24pm UTC](https://forum.inductiveautomation.com/t/write-value-to-tag-using-pushbutton-script/85311/2 "2024-02-06T17:24:03Z")

</div>

I see the creation of a `params` dictionary and nothing else. So the dictionary will be created, then discarded at the end of the script. Your script should look more like:

```auto
	system.tag.writeBlocking(['[RiversideWTPProvider]HighService/HSP No1 Check Valve/OPEN'], [1])

```

Note the placement of the tag path in a string, and both tagpath and value placed inside square brackets to make one-element lists of each. (See the docs for `writeBlocking` for why that is.)

Also, you should not use click events on buttons, as they don't respect the button's enabled/disabled state. Use the `actionPerformed` event instead.

---

<div class="post-metadata">

**Author:** ![ftuquabo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ftuquabo/32/29161_2.png) [@ftuquabo](https://forum.inductiveautomation.com/u/ftuquabo)\
**Post date:** [February 6, 2024, 5:28pm UTC](https://forum.inductiveautomation.com/t/write-value-to-tag-using-pushbutton-script/85311/3 "2024-02-06T17:28:11Z")

</div>

Thank you for the insight!
