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

how to pre select an item in a drop down list

I have a toggle button, which if selected to be ON/Yes/True I want to preselect a specific item in a drop down list.

 

The code I am using is:

 

If(toggle.Value=true,dropdown.Selected.Value="List Item")

 

Not only is the selection not made, but the drop down box (a look up from a sharepoint list) is not populated (for a new entry/blank form) or modified (if I have already made a selection) to reflect my desired change.

 

Is it possible to preselect items in a drop down list (which is a datacardvalue created by powerapps)?

What is wrong with my code above?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: how to pre select an item in a drop down list

Hi @adstar22,

 

The Dropdown.selected.value is a "result", and can't be pre-defined.

The auto-generated Dropdown list for lookup field from SharePoint list, actually acts as the search box, when typing with some string, the dropdown would then send the query to SharePoint server, then return back with the filtered list.

This dropdown box is not the same as the dropdown control.

I have a workaround in such situation:

Under the default porperty, Uncheck the lookup field datacard lock, then change the default property of the dropdown box with the following formula:

If(Toggle2.Value=true,

     {
Value :"235",
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id  :8
        },
  Parent.Default
)

This would have the dropdown display the '@odata.type' field, but the Dropdown.selected value would work.

more info:

Lookup fields under SharePoint list is defined as record type in PowerApps, and for the custom lookup fields, the corresponding elements of the record contains '@odata.type', Id and Value.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: how to pre select an item in a drop down list

Hi @adstar22,

 

The Dropdown.selected.value is a "result", and can't be pre-defined.

The auto-generated Dropdown list for lookup field from SharePoint list, actually acts as the search box, when typing with some string, the dropdown would then send the query to SharePoint server, then return back with the filtered list.

This dropdown box is not the same as the dropdown control.

I have a workaround in such situation:

Under the default porperty, Uncheck the lookup field datacard lock, then change the default property of the dropdown box with the following formula:

If(Toggle2.Value=true,

     {
Value :"235",
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id  :8
        },
  Parent.Default
)

This would have the dropdown display the '@odata.type' field, but the Dropdown.selected value would work.

more info:

Lookup fields under SharePoint list is defined as record type in PowerApps, and for the custom lookup fields, the corresponding elements of the record contains '@odata.type', Id and Value.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
adstar22
Level: Powered On

Re: how to pre select an item in a drop down list

Hi @v-micsh-msft

Having resolved some of the many other issues I have been working through I have spent a couple of hours looking at this, and yor solution works a treat!

 

There are a couple points/items whcih people need to be aware of:

1) The code used is cases sensative for the 3 "field types" (Id Value and 'data type').

2) You MUST ensure that the Value1 = Value in the drop down default settings.

 

I was in the process of writing yet another question.. but did some poking around myself.. and solved the display problem (showing the datatype and not the value).

 

So, yes.. This is brilliant. Thank you very much.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,967)