cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tdupton
Helper II
Helper II

DropDown Default Value

So..I know this must be something simple, but I can't figure it out.  I want to set the default selected value on an edit form for an employee. 

 

Dropdown items come from a SQL Azure table (dbo.Units which has 2 fields UnitID & UnitName).

Dropdown.Items = '[dbo].[Units]'

Dropdown.value=UnitName

Dropdown.default - LookUp('[dbo].[Units]',UnitID=ThisItem.UnitID,UnitName)

 

Why doesn't this select the right unit name?  It always returns the first unit in the table.

 

17 REPLIES 17
Sienna
Memorable Member
Memorable Member

You have to specify row of the table you want to have selected as default in dropdown and not specific column. Use
First('[dbo].[Units]') // for firt line
First(Filter('[dbo].[Units]', UnitID=2)) // for row with UnitID = 2

Thanks.  That still doesn't select the correct value:

 

First(Filter('[dbo].[Units]',UnitID=ThisItem.UnitID)).UnitName

 

I've tried putting this on the default for the datacard and the dropdown control itself.  Neither work.

Sienna
Memorable Member
Memorable Member

I said do not specify column! Use this

First(Filter('[dbo].[Units]',UnitID=ThisItem.UnitID))

You have to specifiy a column.  If not, you get an error saying it's expecting a number but getting a record instead.

Sienna
Memorable Member
Memorable Member

Can you post a screenshot of that error with the code

Capture.PNG

Sienna
Memorable Member
Memorable Member

Hmm... you’re right.. As far as I remember I used to specify row in default of dropdown. However I have just tested it with column and it worked so your code should work just fine

First(Filter('[dbo].[Units]',UnitID=ThisItem.UnitID)).UnitName
Sienna
Memorable Member
Memorable Member

In this case you can try to chage it to only

ThisItem.UnitID
Sienna
Memorable Member
Memorable Member

One more thing... what is in your datacard Items property where you have yor dropdown?

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (20,488)