# Table ID property

**URL:** <https://forum.inductiveautomation.com/t/table-id-property/12749>\
**Category:** Ignition\
**Created:** [March 3, 2017, 3:51pm UTC](https://forum.inductiveautomation.com/t/table-id-property/12749 "2017-03-03T15:51:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dturner](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@dturner](https://forum.inductiveautomation.com/u/dturner)\
**Post date:** [March 3, 2017, 3:51pm UTC](https://forum.inductiveautomation.com/t/table-id-property/12749/1 "2017-03-03T15:51:32Z")

</div>

I am trying to use the 7.9 database manipulation delete button in 7.7.8 but I get a “AttributeError: ‘NoneType’ object has no attribute ‘id’” I went into help to see if that was a property in 7.7.8 but could not find it. I search 7.9 and could not find it there either. Is there something special that needs to be done to access this property?

```auto
id = event.source.parent.getComponent('Inventory').id

if system.gui.confirm("Are you sure you want to delete the selected inventory item?"):
	system.db.runPrepUpdate("DELETE FROM inventory WHERE id = ?", [id])
	system.db.refresh(event.source.parent.getComponent('Inventory'), "data")
	system.gui.messageBox("Inventory item deleted")
```

---

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [March 3, 2017, 3:55pm UTC](https://forum.inductiveautomation.com/t/table-id-property/12749/2 "2017-03-03T15:55:06Z")

</div>

What type of component is “Inventory”? If it’s a text box or number box the attribute might be .text or .int or something like that. id wouldn’t be a property unless you put a custom property on it.

---

<div class="post-metadata">

**Author:** ![dturner](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@dturner](https://forum.inductiveautomation.com/u/dturner)\
**Post date:** [March 3, 2017, 4:12pm UTC](https://forum.inductiveautomation.com/t/table-id-property/12749/3 "2017-03-03T16:12:32Z")

</div>

Inventory is a table. Thank you about the custom property comment. I believe that is it. I will go and look for that.

---

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [March 3, 2017, 4:19pm UTC](https://forum.inductiveautomation.com/t/table-id-property/12749/4 "2017-03-03T16:19:15Z")

</div>

Ok, if you want to get the id of a selected row in the table then you’ll have to create a custom property on the table called “id” and bind it to an expression like this:

`if({Root Container.Inventory.selectedRow} != -1,
{Root Container.Inventory.data}[{Root Container.Inventory.selectedRow}, 0],
0) `

Where the 0 in [{Root Container.Inventory.selectedRow}, 0] is the column index of your ID field in the table.

---

<div class="post-metadata">

**Author:** ![Aaron.Huffman](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@Aaron.Huffman](https://forum.inductiveautomation.com/u/Aaron.Huffman)\
**Post date:** [March 3, 2017, 11:40pm UTC](https://forum.inductiveautomation.com/t/table-id-property/12749/5 "2017-03-03T23:40:46Z")

</div>

You can also do this with a try statement:

```auto
try({Root Container.Inventory.data}[{Root Container.Inventory.selectedRow}, 0],
-1)
```

Also be careful to use -1 and not 0 as the fallback value; you wouldn’t want it to be mistaken for a real id!

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [March 4, 2017, 1:25pm UTC](https://forum.inductiveautomation.com/t/table-id-property/12749/6 "2017-03-04T13:25:26Z")

</div>

```auto
DataTable = event.source.parent.getComponent('Inventory')

id = DataTable.data.getValueAt(DataTable.selectedRow,"id")

if system.gui.confirm("Are you sure you want to delete the selected inventory item?"):
   system.db.runPrepUpdate("DELETE FROM inventory WHERE id = ?", [id],"NameOfDBConnection")
   system.db.refresh(DataTable, "data")
   system.gui.messageBox("Inventory item deleted")
```

---

<div class="post-metadata">

**Author:** ![dturner](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@dturner](https://forum.inductiveautomation.com/u/dturner)\
**Post date:** [March 8, 2017, 4:48pm UTC](https://forum.inductiveautomation.com/t/table-id-property/12749/7 "2017-03-08T16:48:12Z")

</div>

Thank you everyone! Your comments worked.
