# Dropdown Perspective Using Query

**URL:** <https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755>\
**Category:** Ignition\
**Tags:** ignition81, perspective, vision\
**Created:** [June 14, 2022, 4:34pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755 "2022-06-14T16:34:11Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reyes](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@Reyes](https://forum.inductiveautomation.com/u/Reyes)\
**Post date:** [June 14, 2022, 4:34pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/1 "2022-06-14T16:34:11Z")

</div>

Hello,  
I’m trying to use a dropdown input on perspective. I need to get the data for it from a query in my database. Way different than Vision. I created a named query, but yeah ☹ it does not work with the dropdown. Any easy method that you could recommend

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 14, 2022, 4:37pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/2 "2022-06-14T16:37:31Z")

</div>

Can you show the named query you are using and how you are binding it to the data property?

---

<div class="post-metadata">

**Author:** ![Reyes](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@Reyes](https://forum.inductiveautomation.com/u/Reyes)\
**Post date:** [June 14, 2022, 4:43pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/3 "2022-06-14T16:43:33Z")

</div>

![Dropdown](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/2/625b8f11fa144727a80e16f7df25f357c58d6a07.jpeg)

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 14, 2022, 4:44pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/4 "2022-06-14T16:44:27Z")

</div>

Believe you want to bind this to `options`, not `value`. Value is what is currently selected. Options are what they can select from.

---

<div class="post-metadata">

**Author:** ![Arnaud\_Declerck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/arnaud_declerck/32/44872_2.png) [@Arnaud\_Declerck](https://forum.inductiveautomation.com/u/Arnaud_Declerck)\
**Post date:** [June 14, 2022, 4:52pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/5 "2022-06-14T16:52:45Z")

</div>

Hi @Reyes,

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/0/9015b6c75f330987b2784e3539f3b5091644d684.png)  
Like say you need to bind to options.  
I've done the same and my query return a value and label.  
Make sure to set the return format to json.

Regards

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 14, 2022, 4:54pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/6 "2022-06-14T16:54:27Z")

</div>

You will also likely need a transform, since your return dataset has only one column.

E.G a script transform like:

```python
	return [
		{
			"value": row
			"label": row
		} for row in value
	]

```

---

<div class="post-metadata">

**Author:** ![Reyes](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@Reyes](https://forum.inductiveautomation.com/u/Reyes)\
**Post date:** [June 14, 2022, 5:50pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/7 "2022-06-14T17:50:49Z")

</div>

Yes, after binding it to options I have all the data but some errors. I’m trying to add the transform that @paul-griffith said, and I’m looking at the example that @Arnaud_Declerck showed. I really appreciate the help guys.

---

<div class="post-metadata">

**Author:** ![Reyes](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@Reyes](https://forum.inductiveautomation.com/u/Reyes)\
**Post date:** [June 14, 2022, 5:51pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/8 "2022-06-14T17:51:14Z")

</div>

![error](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/d/3df1bd7816513481e05e87a263bc441c0786eab1.jpeg)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 14, 2022, 7:03pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/9 "2022-06-14T19:03:39Z")

</div>

You haven’t added the transform.  
Also expand options.0, etc., to see how the data looks. You should have something like

```auto
options
    0
        value: 1
        label: Option 1
    1
        value: 2
        label: Option 2

```

or, if the value and label are the same as in the transform,

```auto
options
    0
        value: 1
        label: 1
    1
        value: 2
        label: 2

```

---

<div class="post-metadata">

**Author:** ![Reyes](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@Reyes](https://forum.inductiveautomation.com/u/Reyes)\
**Post date:** [June 14, 2022, 9:38pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/11 "2022-06-14T21:38:34Z")

</div>

![errr](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/a/9a0cd3c4166ad90f4cdef5920b62fc0719b96de0.jpeg)

---

<div class="post-metadata">

**Author:** ![Arnaud\_Declerck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/arnaud_declerck/32/44872_2.png) [@Arnaud\_Declerck](https://forum.inductiveautomation.com/u/Arnaud_Declerck)\
**Post date:** [June 14, 2022, 9:42pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/12 "2022-06-14T21:42:34Z")

</div>

set the return format to dataset if you use the transform script.  
if you want to use json as return value then change your query to something like that.

Select name as label,  
name as value  
from qa\_areas

---

<div class="post-metadata">

**Author:** ![Reyes](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@Reyes](https://forum.inductiveautomation.com/u/Reyes)\
**Post date:** [June 14, 2022, 9:59pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/13 "2022-06-14T21:59:24Z")

</div>

It worked! Now it makes sense. You guys were giving me two ways to do that. @De\_Clerck\_ArnI I appreciate your help. Great forum. Thank you all.

---

<div class="post-metadata">

**Author:** ![Craig\_Rice](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@Craig\_Rice](https://forum.inductiveautomation.com/u/Craig_Rice)\
**Post date:** [July 12, 2024, 3:07pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/14 "2024-07-12T15:07:58Z")

</div>

I running into a similar issue. In my case I run a script and get a row of data. I know I need to write a script transform to populate two columns "value" and "label" What would be the correct script as this didn't work

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/a/3af4d3eeecd9f51d9fd1430492a8e6b149e67864.png)

---

<div class="post-metadata">

**Author:** ![Brandon\_Peterson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/brandon_peterson/32/32960_2.png) [@Brandon\_Peterson](https://forum.inductiveautomation.com/u/Brandon_Peterson)\
**Post date:** [July 12, 2024, 3:10pm UTC](https://forum.inductiveautomation.com/t/dropdown-perspective-using-query/60755/15 "2024-07-12T15:10:25Z")

</div>

You're missing a comma, my friend.

```py
return [
	{
		"value": row, # <<< Add this comma here.
		"label": row
	} for row in value
]
```
