# Issue with binding custom parameters to Perspective Dropdown dataset

**URL:** <https://forum.inductiveautomation.com/t/issue-with-binding-custom-parameters-to-perspective-dropdown-dataset/26961>\
**Category:** General Discussion\
**Created:** [July 29, 2019, 6:08pm UTC](https://forum.inductiveautomation.com/t/issue-with-binding-custom-parameters-to-perspective-dropdown-dataset/26961 "2019-07-29T18:08:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerry.buben](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@jerry.buben](https://forum.inductiveautomation.com/u/jerry.buben)\
**Post date:** [July 29, 2019, 6:08pm UTC](https://forum.inductiveautomation.com/t/issue-with-binding-custom-parameters-to-perspective-dropdown-dataset/26961/1 "2019-07-29T18:08:06Z")

</div>

In Vision, I am able to create a SQL query that are (n X m) in dimension and then extract the (m) values into parameters to be used in other components. In Perspective I am having trouble doing this?

I have created a view in Perspective. It contains a Dropdown component that is bound to a named queue:  
SELECT  
OID AS value,  
WRK\_CNTR\_CD AS label,  
DSC  
FROM SAP\_WRK\_CNTR WITH(NOLOCK)  
WHERE PLNT\_CD = :myValueX  
ORDER BY WRK\_CNTR\_CD ASC

Which is returning a dataset of 21x3 and displays it correctly in the dropdown. The selection of the label changes the PROPS.value as expected.

I then added a custom property, on the Dropdown, called test, which has the following property binding and transform

this.props.value

def transform(self, value, quality, timestamp):  
“”"  
Transform the incoming value and return a result.  
Arguments:  
self: A reference to the component this binding is configured on.  
value: The incoming value from the binding or the previous transform.  
quality: The quality code of the incoming value.  
timestamp: The timestamp of the incoming value as a java.util.Date  
“”"  
2 if self.props.value == “”: #account for no selection on dropdown  
3 returnValue = “”  
4 else:  
5 returnValue = self.props.options[value].label  
6 return returnValue

I get the following error message in the script:  
Error\_ScriptEval,”Traceback(most recent call last):  
File “” line 5, in transform TypeError:”’com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataSet’ object is unsubscriptable”)

Have I setup something incorrectly in the Dropdown Dataset that it is not recognizing it as a dataset?

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [July 29, 2019, 6:27pm UTC](https://forum.inductiveautomation.com/t/issue-with-binding-custom-parameters-to-perspective-dropdown-dataset/26961/2 "2019-07-29T18:27:24Z")

</div>

`self.props.options` is an integer-indexed array, not a key-value data type. When you do `self.props.options[value]` you’re trying to access a string-keyed value of `options` when it doesn’t have any. You’ll have to figure out which index in `options` corresponds to your `value` parameter.

You can do it like this:

```python
def getIndex(options, value):
	for idx, option in enumerate(options):
		if(option['value'] == value):
			return idx
	return -1

```

And then you’ll change line 5 to

`returnValue = self.props.options[getIndex(self.props.options, value)].label`

This code should work, I didn’t test it, but I believe this is what you need to go for.

---

<div class="post-metadata">

**Author:** ![jerry.buben](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@jerry.buben](https://forum.inductiveautomation.com/u/jerry.buben)\
**Post date:** [July 29, 2019, 8:00pm UTC](https://forum.inductiveautomation.com/t/issue-with-binding-custom-parameters-to-perspective-dropdown-dataset/26961/3 "2019-07-29T20:00:04Z")

</div>

I have modified the code as follows:

2 def getIndex(options,value):  
3 for idx, option in enumerate(options):  
4 if(option[‘value’] == value):  
5 return idx  
6 return -1  
7   
8 if self.props.value == “”: #account for no selection on dropdown  
9 returnValue = “”  
10 else:  
11 returnValue = self.props.options[getIndex(self.props.options, value)].label  
12 return returnValue

I receive the following error in this case:

Error\_ScriptEval("Traceback(most recent call last):

File '",line 11, in transform  
File"", line 3, in getIndex  
TypeError:‘com.inductive.automation.igniiton.gateway.datasource.BasicStreamingDataset’ object is not iterable")

It is acting like it doesn’t understand the dataset is any array of elements? What am I missing?

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [July 29, 2019, 8:21pm UTC](https://forum.inductiveautomation.com/t/issue-with-binding-custom-parameters-to-perspective-dropdown-dataset/26961/4 "2019-07-29T20:21:05Z")

</div>

Oh right. Yes. You have to do some different manipulation on datasets to do things with them like arrays. If you check out the `system.dataset` documentation there are various ways to work with them.
