Modify selected cell value

Hello,

My name is Pawel and I am new to Ignition Software.

I am trying to create script to modify 1 cell in selected row (Status).
I have copied code from Ignition site, but it give me error.

It changed “scanned” value to “0.0” but then, error is displayed and old value comes back. The value is fixed and will be always the same. 0.0

Error details:
GatewayException: SQL error for “UPDATE tablename
SET columnname = value
WHERE condition”: An expression of non-boolean type specified in a context where a condition is expected, near ‘condition’.
caused by SQLServerException: An expression of non-boolean type specified in a context where a condition is expected, near ‘condition’.

Ignition v7.9.8 (b2018060714)
Java: Oracle Corporation 1.8.0_181

I am trying to solve this problem for the whole day but can’t find working solution. I hope you can help me with this.
All your help is much appreciated.

Best regards
Pawel

Your script is actually fine - the ‘Error running update query’ is a bug on our side in Ignition 7.9.7/7.9.8. Ignition 7.9.9, out within a couple weeks, will fix this issue.

Thank you for quick response. Is there any way around that as temporary solution?

You would have to take the SQL binding off of the table’s data property - or replace it with a named query binding.

1 Like

Thanks for your replay. I did as you suggested. The error is not there, however the new 0.0 value displayed for second and then get back to old value. It look like it wan’t communicate to SQL and replace with new value.

Hi,
I am refreshing this topic as I tried to find the solution in last 2 days, but no success. Not sure if this can be done as value 0.0 stay only until Pooling Mode refreshes the table. Once this happened it get back to old “Scanned” status.
Is there any other way to change selected cell value permanently?
I can add new data in to this table, but can’t modify existing value.

Regards
Pawel

Your problem is that you have two different items writing to the same property: your binding, and your script. You will never get the scripted value to stay there as long as the binding is delivering data. You need two separate properties. A custom property bound to original data, and your script watching for it to update and writing the adjusted dataset to the data property.

1 Like

Thank you for your feedback. Unfortunately, without more details or guidelines I don’t have enough knowledge to complete this task the way you described (I am very new to Ignition). However I found way around this. In general I copied all the data in to variable, then delete the row and add new one with new data. See code below. I know this is not the way it should be done, but at this moment where I try to make few modules as part of the presentation, it will be enough.

Thanks again for all you support guys. It look like I will be quite often here asking for your help.

Code:
data = event.source.parent.getComponent(‘Table’).data
rows = event.source.parent.getComponent(‘Table’).getSelectedRows()

for row in rows:
#get old values
partnumber = data.getValueAt(row, “PartNumber”)
location = data.getValueAt(row, “Location”)
status = data.getValueAt(row, “Status”)
timestamp = data.getValueAt(row, “TimeStamp”)

#identify id for selected valye and remove row
id = data.getValueAt(row, "id")
system.db.runPrepUpdate("DELETE FROM Single WHERE id = ?", [id])

#add new row with new values
newpart_number = partnumber
newlocation = location
newstatus = "Delivered"
newtimestamp = timestamp
deliverytimestamp = system.date.now()
deliverytime = system.date.minutesBetween(newtimestamp, deliverytimestamp)
system.db.runPrepUpdate("INSERT INTO Single (PartNumber, Location, Status, TimeStamp, DeliveredTimeStamp, DeliveryTime) VALUES (?,?,?,?,?,?)", [newpart_number, newlocation, newstatus, newtimestamp, deliverytimestamp,deliverytime])
system.db.refresh(event.source.parent.getComponent('Table'), "data")

system.db.refresh(event.source.parent.getComponent(‘Table’), “data”)