# Populate Perspective-Dropdown

**URL:** <https://forum.inductiveautomation.com/t/populate-perspective-dropdown/25336>\
**Category:** Ignition\
**Created:** [May 27, 2019, 2:10pm UTC](https://forum.inductiveautomation.com/t/populate-perspective-dropdown/25336 "2019-05-27T14:10:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew.Duong](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@Matthew.Duong](https://forum.inductiveautomation.com/u/Matthew.Duong)\
**Post date:** [May 27, 2019, 2:10pm UTC](https://forum.inductiveautomation.com/t/populate-perspective-dropdown/25336/1 "2019-05-27T14:10:16Z")

</div>

Hi,

I am using 8.0.1 perspective module and trying to populate a dropdown. I’ve notice that options is a dictionary with keys inside of a list. So doing this works:

```
dropdownNode = self.getSibling("DropdownNode").props.options
dict = {}
list = []

call = system.db.createSProcCall("cGetAllNodeIdAndLocation","Humidex_r")
system.db.execSProcCall(call)
ds = call.getResultSet()

for row in range(ds.getRowCount()):
	dict[row] = ds.getValueAt(row,"Location")		
	for key,val in dict.items():
		dropdownNode[row].value = key
		dropdownNode[row].label = val

```

I can populate the dropdown, but it will fail if I do not add array element first within the dropdown. So I tried to append this just for testing:

```
dropdownNode = self.getSibling("DropdownNode").props.options
list = []

list.append({"label": "hello", "value":2})
list.append({"label": "goodbye", "value":0})
dropdownNode = list

```

I get no errors with the bottom script in my logs on the gateway, but it doesn’t add a new array element inside the component.

This is the information returned by the stored procedure:

| Id | Location |
| --- | --- |
| 1 | D2ux Weld |
| 2 | RU Weld |
| 3 | KL Weld |
| 4 | C1E2 Weld |
| 5 | W Wax |

Has anyone else ran into this?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 28, 2019, 2:16pm UTC](https://forum.inductiveautomation.com/t/populate-perspective-dropdown/25336/2 "2019-05-28T14:16:20Z")

</div>

You’re approaching this script as if `dropdown` node were a reference, when really it’s a value.

If you want to assign new dropdown options, you would want

```auto
l = []
l.append({'label':'hello','value':2})
l.append({'label':'goodbye','value':0})
self.getSibling('Dropdown').props.options = l

```

`dropdownNode = self.getSibling('Dropdown').props.options` only gets you the VALUE of that attribute - it does not store it as a reference for future manipulation.

Also, please don’t use `list` as a variable name; you can mask a lot of issues by using reserved words/types as variable names.

---

<div class="post-metadata">

**Author:** ![Matthew.Duong](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@Matthew.Duong](https://forum.inductiveautomation.com/u/Matthew.Duong)\
**Post date:** [May 29, 2019, 6:47pm UTC](https://forum.inductiveautomation.com/t/populate-perspective-dropdown/25336/3 "2019-05-29T18:47:56Z")

</div>

Thank you!
