How to use a Script for the onCellEdited Extension Function?

what script is needed to save changes to a power tables dataset? I used the default but it doesn’t seem to work.

import system = system.dataset.setValue(, rowIndex, colIndex, newValue)
1 Like

Did you remember to make the column editable in the Table Customizer?


Where is it getting its underlying data? Like a query or some other operation?

no I just typed it in the dataset

I see your second line is indented in your post - is it like that in the script? That would be a syntax error.

in my script it is right. But it still doesn’t save the data

Not sure where to go from here. Can you upload an export of the window you’re using?

it stores but if I save it in the designer it overwrites it

Same problem, i dont know what to do to allow the user to edit the (23.1 KB)

For these tables - do you have a data query going and does that have polling? If so, any edits you do will be lost the next time the data gets polled.

@bkarabinchak.psi, yes, there is a polling query.

@OscarLucas, you will need to update the database table if you want the change to be permanent.


How? i don´t know how to save data in de BDD

If you have a query polling the database, you dont need to update the dataset, just write to the database and let the query update the table.

You need to add the database name in the update query if not using the default database.
system.db.runPrepUpdate(query, args, “database name”)

Also, you don’t need to import system. that happens automatically.

something like this:

id =, 'id')
query = "Update stock SET %s = ? WHERE id = ?" % (colName)
system.db.runPrepUpdate(query, [newValue, id], "MyDatabase")
system.db.refresh(self, "data")

still not updating the data in the database… Thanks for your comments

Check the console, you’re probably getting an error like Column 'id' doesn't exist because your id column is “idreferencia”, not “id”.

Your column names do not match within your script.

id =, 'idreferencia')
query = 'UPDATE stock SET %s = ? WHERE idreferencia = ?' % (colName)

1 Like

First of all thank you for the help. I’ve tried again and it still doesn’t work. I have checked project properties, I have tried to change the units from the SQL browser successfully and I cannot find the problem in the script.
Does anyone have any idea what might happen?
Anyone have an example that works?

Finally I got it, I leave the example for the whole community.

1 Like