# Boolean Cell - Needs to udpate DB when clicked

**URL:** <https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295>\
**Category:** Ignition\
**Created:** [January 23, 2025, 3:40pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295 "2025-01-23T15:40:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [January 23, 2025, 3:40pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/1 "2025-01-23T15:40:11Z")

</div>

Good morning team!!

I am back again with another problem i need help sovling.

I have a table called drop\_locations.

| area | int | NO | PRI | | |
| --- | --- | --- | --- | --- | --- |
| pos\_a | int | NO | PRI | | |
| command | varchar(100) | YES | | | |
| drop\_location | varchar(6) | NO | PRI | | |
| Active | tinyint(1) | YES | | | |
| content1 | varchar(100) | YES | | | |
| content2 | varchar(100) | YES | | | |

In this table, i want to allow a user to udpate the Active column, the content1 and content2 column.

I could do this with an update query and parameters but was wondering if there was a better way.

I have used this in the past to update an boolean item but never have i used it in a table like this.

```python
def runAction(self, event):
	self.props.selection.data[0].Active = not self.props.selection.data[0].Active

```

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

---

<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:** [January 23, 2025, 3:43pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/2 "2025-01-23T15:43:49Z")

</div>

An update query is your only option here since the data source is a query.

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [January 23, 2025, 3:46pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/3 "2025-01-23T15:46:32Z")

</div>

Great, thanks for teh confirmation.

---

<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:** [January 23, 2025, 3:48pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/4 "2025-01-23T15:48:58Z")

</div>

If your data source's polling is turned off, make sure you refreshBinding() so the data is updated on the front end. I still do this if polling is every 30 seconds or more, so the user does not think the edit was not committed.

Should be similar to this.

```python
self.refreshBinding('props.data')

```

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [January 23, 2025, 6:44pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/5 "2025-01-23T18:44:42Z")

</div>

> [@dkhayes117](#):
>
> make sure you refreshBinding() so the data is updated on the front end. I still do this if polling is ev

Good afternoon Team,

I have updated and created a new query to manage the change.

When using the script below, it does not update active column.

```python
		# update here
		active = self.props.selection.data[0].Active
		content1 = self.props.selection.data[0]['Pallet Location 1']
		content2 = self.props.selection.data[0]['Pallet Location 2']
		drop_location = self.props.selection.data[0]['Drop Location']
		category = "HMI"
		source = "ASCADA Client"
		usr = self.session.props.auth.user.id
		message = str(usr) + " Updated Drop Table to " + str(active) + " Location " + str(drop_location)
		data9 = usr 
						
					# Update drop
		system.db.runNamedQuery("Tables/ASRS Drop Locations Update",{
					"active1": active,
					"contentOne" : content1,
					"contentTwo" : content2,
					"dropLocation" : drop_location,
						})
						
					#Update Syslog		
		system.db.runNamedQuery("Tables/syslog_update",{
					"category": category,
					"source": source,
					"message": message,
					"data9": data9
						})

```

UPDATE QUERY

```python

UPDATE `Clemens`.`drop_locations` 
SET `Active` = :active1, 
	 'content1' = :contentOne 
	 'content2' = :contentTwo 
WHERE (`drop_location` = :dropLocation )

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/1/01aafc75415f0cbc704f769de3253309a86ff2ed.png)

---

<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:** [January 23, 2025, 7:03pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/6 "2025-01-23T19:03:59Z")

</div>

Is your query binding on the table polling or is it turned off?

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [January 23, 2025, 7:04pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/7 "2025-01-23T19:04:53Z")

</div>

It was off, i changed it to polling, 5 secs. Still not working.

---

<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:** [January 23, 2025, 7:09pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/8 "2025-01-23T19:09:41Z")

</div>

Check the gateway logs for scripting errors.

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [January 23, 2025, 7:14pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/9 "2025-01-23T19:14:59Z")

</div>

I see nothing in the gateway logs.

---

<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:** [January 23, 2025, 7:16pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/10 "2025-01-23T19:16:44Z")

</div>

Have you tested the queries to make sure they work?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 23, 2025, 7:51pm UTC](https://forum.inductiveautomation.com/t/boolean-cell-needs-to-udpate-db-when-clicked/101295/11 "2025-01-23T19:51:35Z")

</div>

> [@ahawes](#):
>
> When using the script below, it does not update active column.

Are you sure that you have committed the change?  
Wouldn't you need to update the data with the onEditCellCommit script? Something like,  
`	self.props.data[event.row][event.column] = event.value`  
That would update the cell, and that, in turn, would update the selection data which the first line of your script is referencing.

The script could be written as,

```python
	self.props.data[event.row][event.column] = event.value					

	# Update drop
	system.db.runNamedQuery("Tables/ASRS Drop Locations Update",{
		"active1": self.props.selection.data[0].Active,
		"contentOne": self.props.selection.data[0]['Pallet Location 1'],
		"contentTwo": self.props.selection.data[0]['Pallet Location 2'],
		"dropLocation": self.props.selection.data[0]['Drop Location']
	})
						
	#Update Syslog		
	system.db.runNamedQuery("Tables/syslog_update",{
		"category": "HMI",
		"source": "ASCADA Client",
		"message": str(usr) + " Updated Drop Table to " + str(active) + " Location " + str(drop_location),
		"data9": usr 
	})
```
