Power Table for loop for each row

I trying to run an update named query for each row on a power table. I set up the power table that can “pick up and drag” each row. Each row is number in the database. The update is to change the number.

table = event.source.parent.getComponent(‘Goals_Year’)
rowCount = event.source.parent.getComponent(‘Goals_Year’).data.getRowCount()

for row in range(rowCount):
selectId = event.source.parent.getComponent(‘power table’).data[row, “Id”]
newValue = row

namedQuery = 'Update'
params = {
	'newValue':newValue, 
	'Id':selectId
	}
system.db.runNamedQuery(namedQuery, params)

system.db.refresh(table, ‘data’)

I believe the error is on the for loop line. Right now the script is in a button on the window.

looking into this more this line isn’t working.
selectId = event.source.parent.getComponent(‘power table’).data[row, “Id”]

I use something like this in an expression binding witch works.

{Root Container.power table.data} [{Root Container.power table.selectedRow} , “Id”]

So I have to pull data out of the row in scriping not expression. Any help would be helpful.

Got it.

table = event.source.parent.getComponent(‘power table’)
rowCount = event.source.parent.getComponent(‘power table’).data.getRowCount()

rowselect = 0

for row in range(rowCount):
selectId = event.source.parent.getComponent(‘power table’).data.getValueAt(row, “Id”)
newValue = rowselect + 1

namedQuery = 'Update'
params = {
	'newValue':newValue, 
	'Id':selectId
	}
system.db.runNamedQuery(namedQuery, params)

rowselect = newValue

system.db.refresh(table, ‘data’)