How to Enter Time stamp when Power Table Cell is Updated

I am using the following script to Update changes made to a Power Table.

row = rowIndex
col = colIndex
colName = colName
value = newValue
		
ndx = self.data.getValueAt(row,0)
query = "UPDATE brewdaily SET %s = ? WHERE ndx = ?" % colName
system.db.runPrepUpdate(query,[value,ndx],'history')
system.db.refresh(self.data)

This table (brewdaily) is for operators to check off their daily tasks.
When they are viewing this PowerTable they see -

How can I enter a timestamp into column “Time Stamp” when the operator checks one of the corresponding cells in the Column labeled “Complete”?

I am not sure how efficient this is, but the following script appears to be doing what I intended.
I would still appreciate ant help this forum can offer in improving it.

Your code looks fine - you should probably check whether the edited cell is in the appropriate column (unless you’re already doing that, higher up in the script). Also, you can combine your UPDATE statements into one call - just combine the two columns:

query = """
UPDATE
    brewdaily
SET
    %s = ?
    t_stamp = ?
WHERE
    ndx = ?
""" % colName
system.db.runPrepUpdate(query, [value, EntryTime, ndx], 'history')

(Also - indenting the SQL like that is totally optional; but in my opinion, makes it a lot more readable over time).

How would I check for the appropriate column being checked?

onCellEdited passes a colName parameter to you, which you could check to make sure the column that was edited is one of the columns you expect - although, actually, what I thought might happen (circular referencing, where editing ‘complete’ edits ‘t_stamp’ and fires the script again) won’t actually happen due to the way onCellEdited works.

First I simplified my query as you suggested. Still works great. But enters the Time when any cell is edited. Then I made some (rookie) attempts at targeting the column “Complete”. So far no luck.
if colName == ‘complete’:

…and then it goes bad.

Looks like you have capitalized complete so maybe:

if colName == 'Complete':
    #your script here

You might also consider using the table customizer to make only the complete column editable by the user.

May want to set the timestamp from the query. Not sure if system.date. now uses the gateway or client time.