# Dropdown return value

**URL:** <https://forum.inductiveautomation.com/t/dropdown-return-value/72910>\
**Category:** Ignition\
**Tags:** perspective, ignition81, scripting\
**Created:** [April 26, 2023, 10:25am UTC](https://forum.inductiveautomation.com/t/dropdown-return-value/72910 "2023-04-26T10:25:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saravanan\_Manickam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@saravanan\_Manickam](https://forum.inductiveautomation.com/u/saravanan_Manickam)\
**Post date:** [April 26, 2023, 10:25am UTC](https://forum.inductiveautomation.com/t/dropdown-return-value/72910/1 "2023-04-26T10:25:52Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/2/8216c3f1edd4c566ed229ae5af5feda415f5cd24.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/e/ce61422ca740410c0325a732aba6d11af3c21600.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/b/db7d0224318e2dff653b7fd6c48ec9d663d572cc.png)  
Here I have a dropdown for that data I have fetch from the database

so the output is dataset....for that I have converted into label and value by script on transform

while rederiving the data I the label data doesn't populate

thanks in advance

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 26, 2023, 12:16pm UTC](https://forum.inductiveautomation.com/t/dropdown-return-value/72910/2 "2023-04-26T12:16:47Z")

</div>

Remove the transform. You don't need it here, your query already returns a list of `value` and `label`.

If you don't want your 'options' to be a dataset, you can just change the return type of the query binding to `json`.

But let's fix that transform script anyway, for learning sake.  
Let's imagine your query doesn't return 'label' and 'value' but 'name' and 'val', and some other columns you don't want.

With query return type set to dataset, and returning a dataset (could be made shorter, but for simplicity's sake I made every step explicit):

```python
label_index = value.getColumnIndex('name')
value_index = value.getColumnIndex('val')
headers = ['label', 'value']
data = zip(
	value.getColumnAsList(label_index),
	value.getColumnAsList(value_index)
)
return system.dataset.toDataSet(headers, data)

```

With return type set to json, and returning an array of objects (json like):

```python
	return [
		{
			'label': row['name'],
			'value': row['val']
		} for row in value
	]

```

Oh and there's something I forgot to mention:  
At the end of your transform, you set the `self.props.options`, and then return them.  
That's not how binding work.  
The property that has the binding will receive the value returned. You don't need to set it manually.  
so, instead of

```python
self.props.options = x
return self.props.options

```

you should do

```python
return x

```

---

<div class="post-metadata">

**Author:** ![saravanan\_Manickam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@saravanan\_Manickam](https://forum.inductiveautomation.com/u/saravanan_Manickam)\
**Post date:** [April 27, 2023, 5:22am UTC](https://forum.inductiveautomation.com/t/dropdown-return-value/72910/3 "2023-04-27T05:22:15Z")

</div>

ok thank you for making me aware of it , let me try this logic too.

the issue is resolved.

Solution : while retrieving the data in a dataset and converted into list so the value datatype changed as string by casting it into int .it's working (EX: int(data))
