cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tdupton
Level: Powered On

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
Level 10

Re: DropDown Default Value

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
tdupton
Level: Powered On

Re: DropDown Default Value

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
Level 10

Re: DropDown Default Value

I said do not specify column! Use this

First(Filter('[dbo].[Units]',UnitID=ThisItem.UnitID))
tdupton
Level: Powered On

Re: DropDown Default Value

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

Sienna
Level 10

Re: DropDown Default Value

Can you post a screenshot of that error with the code
tdupton
Level: Powered On

Re: DropDown Default Value

Capture.PNG

Sienna
Level 10

Re: DropDown Default Value

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
Level 10

Re: DropDown Default Value

In this case you can try to chage it to only

ThisItem.UnitID
Sienna
Level 10

Re: DropDown Default Value

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

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,794)