# Edicion de una tabla con onCellEdited

**URL:** <https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058>\
**Category:** Ignition\
**Created:** [June 22, 2022, 2:01pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058 "2022-06-22T14:01:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 2:01pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/1 "2022-06-22T14:01:54Z")

</div>

saludos estoy configurando una tabla con onCellEdited uso la versión 7.9 este es mi código

```auto
row = rowIndex
col = colIndex
colName = colName

ID = self.data.getValueAt(rowIndex,'id')
query = "UPDATE AguaControl.Agua SET %s = ? WHERE id = ?" %(colName)
system.db.runPrepUpdate (query,ID,'AguaControl')
system.db.refresh(self,"data")

```

pero no me funciona no se donde esta el error podrian ayudarme

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [June 22, 2022, 2:32pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/2 "2022-06-22T14:32:57Z")

</div>

You probably need your runPrepUpdate parameters in a list. You also need as many items in this list as there are question marks in your query.

`system.db.runPrepUpdate (query,[SET_VALUE,ID],'AguaControl')`  
fill the variable SET\_VALUE however you would like.

[Ignition Docs](https://docs.inductiveautomation.com/display/DOC79/system.db.runPrepUpdate)

---

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 3:04pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/3 "2022-06-22T15:04:59Z")

</div>

```auto
query = "UPDATE AguaControl.Agua SET Consumo_Total = ? WHERE id = ?" %(colName)
system.db.runPrepUpdate (query,[id,Consumo_Total])

```

complete mi codigo y lo reduje de esta manera pero aun no me funciona cual es mi error ?

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [June 22, 2022, 3:07pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/4 "2022-06-22T15:07:50Z")

</div>

Your parameters need to be in the order of the question marks.

Try:  
`system.db.runPrepUpdate (query,[Consumo_Total,id])`

If that doesn’t work, copy the error message and post it here.

---

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 3:28pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/5 "2022-06-22T15:28:25Z")

</div>

lo hice pero no funciono y no puedo publicarte un error porque no me reflejo uno simplemente la tabla no se deja editar me siento en un callejón sin salida

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [June 22, 2022, 3:40pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/6 "2022-06-22T15:40:50Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/e/eea20499ceff420aaa74ecb0c499c59bdd8ddd52.png)

Open the console and see if there is an error message.

If there isn’t an error message, try calling IA support.

---

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 3:45pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/7 "2022-06-22T15:45:50Z")

</div>

tenias razon

```auto
Caused by: org.python.core.PyException: Traceback (most recent call last):
  File "<extension-method onCellEdited>", line 27, in <module>
NameError: name 'self' is not defined

```

este es mi error

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 22, 2022, 3:47pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/8 "2022-06-22T15:47:35Z")

</div>

This line:

```auto
ID = self.data.getValueAt(rowIndex,'id')

```

Needs to be

```auto
ID = event.source.data.getValueAt(rowIndex,'id')

```

---

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 3:50pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/9 "2022-06-22T15:50:51Z")

</div>

```auto
Caused by: org.python.core.PyException: Traceback (most recent call last):
  File "<extension-method onCellEdited>", line 27, in <module>
NameError: name 'event' is not defined

```

tengo este error ahora

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 22, 2022, 3:56pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/10 "2022-06-22T15:56:06Z")

</div>

> [@JHON\_FLOREZ](#):
>
> `onCellEdited`

Sorry... it should be self.data not event.source.

Can you post your entire script including the def onCellEdited part all the way to the bottom?

---

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 3:58pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/11 "2022-06-22T15:58:25Z")

</div>

```auto
#rowIndex = row
#colIndex = col 
#colName = colName

ID = self.data.getValueAt(rowIndex,'id')
query = "UPDATE AguaControl.Agua SET %s = ? WHERE id = ?"%(colName)
system.db.runPrepUpdate(query, [value,ID], 'AguaControl')
system.db.refresh(self,"data")

```

este es

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 22, 2022, 4:00pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/12 "2022-06-22T16:00:15Z")

</div>

You are missing the

```auto
def onCellEdited

```

at the beginning. I want to see the ENTIRE script not just your part (If you can)

---

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 4:02pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/13 "2022-06-22T16:02:40Z")

</div>

si claro, aqui esta :

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/6/5678211b75c4b5daf1b0097a310991734c7310a3.png)

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 22, 2022, 4:06pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/14 "2022-06-22T16:06:32Z")

</div>

OK… all your scripting is not indented properly.

You need to indent each of your lines with a tab to be properly indented.

---

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 4:14pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/15 "2022-06-22T16:14:07Z")

</div>

ENTIEDO

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/2/d20d4a31421baf71c6b51aa817b2e362ba2252c3.png)  
lo hice asi pero me aparece un error en la primera linea  
al momento de dejarlo sin sangria el error desaparece

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 22, 2022, 4:21pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/16 "2022-06-22T16:21:37Z")

</div>

> [@JHON\_FLOREZ](#):
>
> ```auto
> #rowIndex = row
> #colIndex = col 
> #colName = colName
> 
> ID = self.data.getValueAt(rowIndex,'id')
> query = "UPDATE AguaControl.Agua SET %s = ? WHERE id = ?"%(colName)
> system.db.runPrepUpdate(query, [value,ID], 'AguaControl')
> system.db.refresh(self,"data")
> 
> ```

If you hover your mouse over the red mark you might get an idea of the error

You have got some fundamental issues with your script. You are writing to rowIndex,colIndex etc...

Try this:

```auto
	ID = self.data.getValueAt(rowIndex,"id")
	query = "UPDATE Agua SET %s = ? WHERE id = ?" %(colName)
	system.db.runPrepUpdate(query, [newValue,ID], "AguaControl")
	system.db.refresh(self,"data")

```

Remove all the code that you have an just put that in. Make sure that it is properly indented.

---

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 4:47pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/17 "2022-06-22T16:47:46Z")

</div>

tengo este error

```auto
 Error invoking extension method.
org.python.core.PyException: Traceback (most recent call last):
  File "<extension-method onCellEdited>", line 24, in onCellEdited
TypeError: not all arguments converted during string formatting

```

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 22, 2022, 4:56pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/18 "2022-06-22T16:56:52Z")

</div>

So are things working or do you still have issues?

---

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 4:59pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/19 "2022-06-22T16:59:06Z")

</div>

aun tengo problemas

```auto
ERROR Vision.Components.AdvancedTable - Error invoking extension method.
org.python.core.PyException: Traceback (most recent call last):
  File "<extension-method onCellEdited>", line 25, in onCellEdited

```

este es mi error

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 22, 2022, 5:01pm UTC](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058/20 "2022-06-22T17:01:54Z")

</div>

> [@JHON\_FLOREZ](#):
>
> aun tengo problemas

OK... can you post your entire script again? Use the \</\> option to post it. Please include the entire script.

[Next page](https://forum.inductiveautomation.com/t/edicion-de-una-tabla-con-oncelledited/61058.md?page=2)
