# Accessing Component Properties from Extension Function

**URL:** <https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730>\
**Category:** Ignition\
**Tags:** ignition78, scripting\
**Created:** [July 9, 2017, 4:19pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730 "2017-07-09T16:19:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![robert1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@robert1](https://forum.inductiveautomation.com/u/robert1)\
**Post date:** [July 9, 2017, 4:19pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/1 "2017-07-09T16:19:18Z")

</div>

Hello-

I’m hoping to get some help with embedded dropdown list in PowerTable component. I have a table which I would like to select a variety from Column 0 dropdown (filled out by SQL query) and then Col1 is a lot code dependent on selection in Col0. I’m not sure how to link to value at selectedRow, Collumn0 like I would outside the extension function. Here’s what I have that is not working:

```
query = "SELECT DISTINCT ItemName FROM raw_materials_list WHERE ItmsGrpNam = 'Hops'"
hops = system.db.runQuery(query, 'Quality')
hops_options = []

for row in hops:
    hops_options.append((row[0],row[0]))

hop_var = self.data.getValueAt(self.selectedRow, 0)
query = "SELECT DISTINCT LotCode FROM raw_materials_list WHERE ItemName = '%s'" %hop_var
lots = system.db.runQuery(query, 'Quality')
lots_options = []

for row in lots:
	lots_options.append((row[0],row[0]))

if colName == 'Hop Variety':
    return {'options': hops_options}

elif colName == 'Lot Code':
    return {'options': lots_options}

```

The ‘Hop Variety’ dropdown works fine, but I’m not sure how to get the right value into hop\_var so that ‘Lot Code’ query works (i’ve tried a few different things). What is the correct way to access the PowerTable’s component properties from its own extension function?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 9, 2017, 4:30pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/2 "2017-07-09T16:30:56Z")

</div>

Hello,

From within your extension function you can access your other component properties in the following way:

```auto
col0Value = self.data.getValueAt(self.selectedRow,"col0")

```

---

<div class="post-metadata">

**Author:** ![robert1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@robert1](https://forum.inductiveautomation.com/u/robert1)\
**Post date:** [July 9, 2017, 4:59pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/3 "2017-07-09T16:59:24Z")

</div>

Thanks, Nick!

I changed hop\_var to this (“Hop Variety” is col name), but still not working:

```
query = "SELECT DISTINCT ItemName FROM raw_materials_list WHERE ItmsGrpNam = 'Hops'"
hops = system.db.runQuery(query, 'Quality')
hops_options = []

for row in hops:
	hops_options.append((row[0],row[0]))

hop_var = self.data.getValueAt(self.selectedRow, "Hop Variety")
query = "SELECT DISTINCT LotCode FROM raw_materials_list WHERE ItemName = '%s'" %hop_var
lots = system.db.runQuery(query, 'Quality')
lots_options = []

for row in lots:
	lots_options.append((row[0],row[0]))

if colName == 'Hop Variety':
	return {'options': hops_options}

elif colName == 'Lot Code':
	return {'options': lots_options}

```

Sorry if I’m completely missing something stupid! This works fine when I just sub in hop\_var = ‘Cascade’ so it is a problem with that particular getValueAt line

---

<div class="post-metadata">

**Author:** ![robert1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@robert1](https://forum.inductiveautomation.com/u/robert1)\
**Post date:** [July 9, 2017, 5:06pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/4 "2017-07-09T17:06:13Z")

</div>

It works with:

```
hop_var = self.data.getValueAt(0,0)

```

so it must be an issue with “self.selectedRow”?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 9, 2017, 5:26pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/5 "2017-07-09T17:26:37Z")

</div>

Are you sure you had the column name right? What if you accessed the column with a integer instead of a string?

---

<div class="post-metadata">

**Author:** ![robert1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@robert1](https://forum.inductiveautomation.com/u/robert1)\
**Post date:** [July 9, 2017, 5:31pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/6 "2017-07-09T17:31:05Z")

</div>

Yes, this also does not work:

```
hop_var = self.data.getValueAt(self.selectedRow,0)

```

Its also not popping up with an error message, its just not showing the dropdown on either column. Do you know where I can find the error? That might make it easier to figure out.

---

<div class="post-metadata">

**Author:** ![robert1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@robert1](https://forum.inductiveautomation.com/u/robert1)\
**Post date:** [July 9, 2017, 6:02pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/7 "2017-07-09T18:02:09Z")

</div>

What I have posted above is the entire script in the configureEditor extension function. Should I need to import something into this script to make the selectedRow property accessible? It would be weird though if I can get to self.data and not self.selectedRow though, yes?

---

<div class="post-metadata">

**Author:** ![robert1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@robert1](https://forum.inductiveautomation.com/u/robert1)\
**Post date:** [July 9, 2017, 6:19pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/8 "2017-07-09T18:19:41Z")

</div>

Found this in output console:

```
ERROR [AdvancedTable-AWT-EventQueue-2] Error invoking extension method.
 Traceback (most recent call last):
  File "<extension-method configureEditor>", line 33, in configureEditor
    at com.inductiveautomation.ignition.common.BasicDataset.getValueAt(BasicDataset.java:114)
    at sun.reflect.GeneratedMethodAccessor237.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)

java.lang.ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: -1
```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 9, 2017, 7:22pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/9 "2017-07-09T19:22:07Z")

</div>

You seem to think this extension function is called as you navigate in the table. It is called once for each column during setup of the table. If you search the forum for “configureEditor”, you’ll see a number of discussions and the custom editor you would need.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 10, 2017, 12:53am UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/10 "2017-07-10T00:53:55Z")

</div>

Perhaps you should use the “onCellEdited” extension function instead of the configureEditor extension function.

---

<div class="post-metadata">

**Author:** ![robert1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@robert1](https://forum.inductiveautomation.com/u/robert1)\
**Post date:** [July 10, 2017, 4:32am UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/11 "2017-07-10T04:32:19Z")

</div>

> [@pturmel](#):
>
> You seem to think this extension function is called as you navigate in the table.

Ah, yes! This is the "completely stupid thing I am missing"- this issue makes a lot more sense now :). I'll look into the custom editor, I wasn't quite sure what to search for before. Thanks for the clarification.

---

<div class="post-metadata">

**Author:** ![dmdrendall](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@dmdrendall](https://forum.inductiveautomation.com/u/dmdrendall)\
**Post date:** [October 15, 2018, 4:22pm UTC](https://forum.inductiveautomation.com/t/accessing-component-properties-from-extension-function/14730/12 "2018-10-15T16:22:57Z")

</div>

Hi Nick,

Does the SDK reveal which libraries a particular extension function or event handler is using?

I’m modifying the visibility of certain y-axes on an EasyChart using the configureChart extension function. Originally, I thought that changing the state of a value in the configureChart function would invoke that function, but it appears it’s only called for a limited set of events.

My plan is to move the script from the configureChart extension function to a checkbox event handler function. Will I need to figure out which underlying libraries of the configureChart function is using so as to import them into the event handler function?
