cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

ComboBox default selected items from a collection doesn't work

Hello everyone.

I'm having troubles loading defaults into a combobox, from a collection.

I have a ComboBox that's defined like this:

The SelectedItems is a collection that's collected by calling

 

ClearCollect(SelectedItems,ComboBox1.SelectedItems);SaveData(SelectedItems, "SavedSelectedItems");

So it's expected that when the SelectedItems collection isn't empty, it will have those entries selected as default.

 

However, this is only partly working.

 

The preview of the ComboBox looks fine, like this:

However, when you press it, the items aren't actually selected.

What am I doing wrong?
I uploaded a simple reproduction project and attached to this topic, if you want to try it out and see what I mean.

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous ,

Could you please share a bit more about your SelectedItems collection?

 

I have made a test on my side, and found that there is something issue with the value you typed within the DefaultSelectedItems property of the ComboBox.

Please take a try with the following workaround for more details:4.JPG

 

5.JPG

Set the DefaultSelectedItems property of the ComboBox to following:

ForAll(
       SelectedItems,
       {
           Value: Value
       }
)

On your side, please consider take a try to set the DefaultSelectedItems property of your ComboBox to following:

ForAll(
       SelectedItems,
       {
           Value: Value
       }
)

then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
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

9 REPLIES 9
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Based on the issue that you mentioned, I think you have some misunderstanding with the DefaultSelectedItems property of the ComboBox control.

 

The DefaultSelectedItems property of the ComboBox control is used to set a Default value within the ComboBox control. But the Default value just be displayed within the ComBoBox, rather than select corresponding values from the ComboBox available options and display it.

 

In other words, the Default value just be used as a Display value within the ComboBox, which would not be recognized that you selected corresponding values from the ComboBox available options.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you.

So just to clarify is it not possible having a ComboBox that has some items selected by default?

 

 

 

Hi @Anonymous ,

Could you please share a bit more about your SelectedItems collection?

 

I have made a test on my side, and found that there is something issue with the value you typed within the DefaultSelectedItems property of the ComboBox.

Please take a try with the following workaround for more details:4.JPG

 

5.JPG

Set the DefaultSelectedItems property of the ComboBox to following:

ForAll(
       SelectedItems,
       {
           Value: Value
       }
)

On your side, please consider take a try to set the DefaultSelectedItems property of your ComboBox to following:

ForAll(
       SelectedItems,
       {
           Value: Value
       }
)

then check if the issue is solved.

 

Best regards,

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

In your DefaultSelectedItems field place an array value. i.e. Use brackets notation [fieldname]

e.g. For a collection field called 'amount' just put [amount] in the default selected field.

@infoman Hi,

 

Can you elaborate please? I've a collection which is storing the selected items from a combobox control. That is fine. However, when i'm trying to default the selected items, it's throwing an error. I tried wrapping the column name from the collection in square brackets. But it didn't work.

 

Much appreciated if you can share more details.

 

Thanks,

Sasi.

ramanujama
Advocate I
Advocate I

It is really simple.
Example you have an Employee table with columns: Id, Name

Suppose you have created a Combobox for email and selected A, B, C and saved it in database. When you load the page or comes again, you want those items to be selected as default, use below formula:

DefaultSelectedItems = Filter(Employees, Name in Split(EmailList,","))

Note: EmailList is coming from database (previously saved value)

Above formula selects items in combobox as well.

Anonymous
Not applicable

It will work on multiple selection =true or false both Filter(ListName, Columnname in Parent.Default)

It does not with the code for me and I don't understand why not. 

 

Mine is a lookup column11_1.PNG

Excellent!! 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,373)