# Perspective dropdown How to Default to the First Value?

**URL:** <https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 20, 2023, 3:35pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285 "2023-06-20T15:35:12Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [June 20, 2023, 3:35pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/1 "2023-06-20T15:35:12Z")

</div>

I have some dropdowns with their options bound to a dataset. When the dataset updates the dropdowns are left showing the "Select..." text. Is there a way to have them default to an option in the dataset?

I did find some posts using selectedValue property but I guess that is for the View dropdown and isn't it read only?

event.source.parent.getComponent('Dropdown 1').selectedValue = 0

---

<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 20, 2023, 6:05pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/2 "2023-06-20T18:05:17Z")

</div>

Try this:

- Create `custom.dd1options` on the dropdown. Bind that to the dataset source.
- Bind the dropdown `options` to `custom.dd1options`. The dropdown options will automatically update any time the dataset changes.
- Put an expression binding on the dropdown `value` property. Configure the expression as shown below.  
 ![Dropdown default](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/0/002b1cf08b3804189d9a29c00bcab9f803bce831.png)

The expression will be executed any time the dataset changes on `custom.dd1options`. The transform will return the value of option 0.  
`

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 20, 2023, 6:17pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/3 "2023-06-20T18:17:46Z")

</div>

I don't think you need the expression transform. Just the expression binding:

```auto
{this.custom.options}[0]["value"]

```

---

<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 20, 2023, 6:25pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/4 "2023-06-20T18:25:48Z")

</div>

> [@lrose](#):
>
> I don't think you need the expression transform.

You are correct!

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 20, 2023, 6:46pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/5 "2023-06-20T18:46:01Z")

</div>

Wouldn't that binding stop you from selecting something other than the first option? I figure you'd need a property change script on the data binding, then set the selected value to the first result when it changes.

---

<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 20, 2023, 6:50pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/6 "2023-06-20T18:50:31Z")

</div>

My understanding is that the binding only executes when `custom.dd1options` changes. The user is free to choose any option in the meantime.

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [June 20, 2023, 10:15pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/7 "2023-06-20T22:15:59Z")

</div>

After making the changes it's showing the updated dataset like before but is still showing "Select..." text after the dataset is changed.

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

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/6/66c78764009d469d797076d4ed962aa68c1b9146.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/d/4d0fdbc3199675d234e70acc084fb05c714fc2a1.png)

When adding the value expression binding there is a error.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/a/da568f86c32c0da9a2649ef1bcb56535941936bb.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/f/6f76024ba32a19645601e4d43266025095e6aa4b.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/c/ece0de589210cfa85494033876f2d4b9c153b6aa.png)

---

<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 20, 2023, 10:44pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/8 "2023-06-20T22:44:47Z")

</div>

Nice well-cropped screen grabs!

- The first binding looks correct. The `custom.dd5option` is bound correctly and you have a 2 x 2 dataset.
- The second binding looks correct. It should be returning a copy of the previous dataset.
- I think the last binding be  
`{this.custom.dd5options}[0]["value"]`  
You need to point it to the custom prop as the `Dropdown_lineup.props.options` binding.

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [June 20, 2023, 11:06pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/9 "2023-06-20T23:06:11Z")

</div>

That would make sense. Now I get a conversion error and the report that is using the pulldown is looping.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/3/5381c1879873a9f8e516f010937376f3bf4352b8.png)

`{this.custom.dd5option}[0]["value"]`  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/d/dd040a7afca5bb46eda224d6164bc853cfbc6782.png)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 20, 2023, 11:13pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/10 "2023-06-20T23:13:42Z")

</div>

What does it say if you hover over the red error text?

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [June 20, 2023, 11:15pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/11 "2023-06-20T23:15:35Z")

</div>

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

But at this point you don't want array or dataset.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 20, 2023, 11:17pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/12 "2023-06-20T23:17:36Z")

</div>

Actually it wants just that, or I doubt that it would tell you other wise.

What happens if you change the expression binding to this:

```auto
{this.custom.dd5option}[0]

```

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [June 20, 2023, 11:24pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/13 "2023-06-20T23:24:35Z")

</div>

The Options should have and is a dataset but the value should just be a value. ???

No error after removing the "["value"]" from the end but the dropdown can not be set to anything and is now always blank and the report is looping or updating over and over.

When I click on it, it has the correct dataset or options but whatever is selected it just goes blank again.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/1/31d82cdfb45952183780ba1399ebc40919793311.png)

---

<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:** [June 21, 2023, 2:37pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/14 "2023-06-21T14:37:30Z")

</div>

Some important points here:

1. If your Dropdown is configured to be multi-select, value _will_ expect an array or list.
2. You might consider use of a change script on the custom property instead, which writes the 0th value to the `value` prop.

---

<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:** [June 21, 2023, 4:04pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/15 "2023-06-21T16:04:51Z")

</div>

`{this.custom.dd5option}[0, 'value']`

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [June 21, 2023, 4:18pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/16 "2023-06-21T16:18:59Z")

</div>

The option multiSelect is false.

One issue was the expression tags updating the datasets was running fixed rate. I changed then to event driven and it's no longer looping but it seems the last step to update the dropdowns selection is not happening.

Just seeing the post from @pascal.fragnoud and it seems to work now with the Dropdown\_Lineup.props.value expression binding.

Not sure what the working code would be for the change script would be.

---

<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:** [June 21, 2023, 4:50pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/17 "2023-06-21T16:50:17Z")

</div>

Something like

```python
self.props.value = currentValue.value[0].value

```

use the property browser to make sure the paths are correct.

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [June 28, 2023, 12:02am UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-how-to-default-to-the-first-value/75285/18 "2023-06-28T00:02:31Z")

</div>

The dropdown value expression binding worked well until today. For some reason it now updates every second even though nothing has changed, so the report just keeps loading over and over. I was working on an unrelated button on the Perspective screen and the report just started loading.

The other day I had to change the memory tag expression that creates the dataset for the dropdown from fixed rate execution mode to event and the fixed the looping until today.

I don't know how it was working before. I even did a gateway restore from yesterday and the reports still loop. ???

Looking at the memory tags expression, there is a poll rate argument in the runScript function and it was set to 1 second. It seems it's not decided that this is a change and is updating the report even thought the values passed to the report unchanged. What the?
