cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
NigelP
Level 8

DefaultSelectedItems not not available when used on a OnSelect Property

Hi

 

I have a Combo Box which has a propert DefaultSelectedItems which has a formual in it which works OK.

 

On a button, seperate to the ComboBox I try select the combox eg AssuranceStatus hit the '.', I see selectedItems, but not Default SelectedItems.

 

Why ?

 

I want to update the field which is bound to the comboBox before I save the form.  I thought you could use DefaultSelectedItems to do this, just like the property on the ComboBox.

 

Regards

 

Nigel

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft dinusc
Microsoft

Re: DefaultSelectedItems not not available when used on a OnSelect Property

Hello Nigel,

I'm sorry for confusing you. SelectedItems is the output property and cannot be set. This is the reason you see it when you press "." as you mentioned in your first message.

Now, DefaultSelectedItems is an input property and it can be set. For this reason, it will not show in the list of properties when you press "."

The rest of my message seems correct ("SelectedItems" should be replaced with "DefaultSelectedItems"). 

Some of the controls properties in PowerApps are bi-directional, which means that those can be set and also can be read (can be accessed on pressing ".").

For your ComboBox card in the form, all you need to do is to set the DefaultSelectedItems. For a new ComboBox instance, those will become your selected items as well so if you submit your form then those values will be stored. If however you select some items manually then those will become selected items and will be stored. If you reset your ComboBox (Reset(ComboBox1)) then the manually selected items will be removed and default selected items will become again selected. 

Please let me know if you have any questions.

View solution in original post

5 REPLIES 5
Microsoft dinusc
Microsoft

Re: DefaultSelectedItems not not available when used on a OnSelect Property

Hello Nigel,

 

DefaultSelectedItems is the property that is used "by default" when the ComboBox is reset or is newly created.

In order to save selected items to the bound source, you do not need DefaultSelectedItems. Please check the card's "Update" property. For your ComboBox it should be set to the SelectedItems, not DefaultSelectedItems.

Aside from that, you can still set the DefaultSelectedItems via a variable, if you want.

NigelP
Level 8

Re: DefaultSelectedItems not not available when used on a OnSelect Property

Hi

 

So how do I set the ComboBox's SelectedItems to a value (which is one of the choice field Values) ?

 

Thanks

 

Nigel

Microsoft dinusc
Microsoft

Re: DefaultSelectedItems not not available when used on a OnSelect Property

Assuming you use Forms with ComboBox based cards, you don't need to do anything special for saving the value. For selecting values programmatically, you can do:

ComboBox.SelectedItems=["one", "two"]

or bind via a variable:

ComboBox.SelectedItems=sel

Set(sel, ["one", "two"]);

This will select 2 values. Calling SubmitForm(YourFormName) should save them to your list.

If you don't use forms and cards then it's a little ibit more complicated to save choice based fields. See this page for more details:

https://powerusers.microsoft.com/t5/General-Discussion/How-to-Save-Choice-field-value-using-UpdateIf...

NigelP
Level 8

Re: DefaultSelectedItems not not available when used on a OnSelect Property

Hi

 

My Combo box is tied to a choice field consisting of 4 string values.

The Choice Field is part of a SharePoint Online List.

If I have a line saying ComboBox.SelectedItem = ["In Assurance"] (one of the 4 choices mentioned above) as per your response I get a little wavy red line under the equals sign, which when I hover over it, it says "Invalid Argument Type".  It does not tell me what argument type it does want !

 

I have tried putting the value into a global variable Set(gAssuranceStatus,["In Assurance"]) and setting ComboBox.SelectedItems = gAssuranceStatus, same result.  I tried ClearCollect(colAssuranceStatus, gAssuranceStatus) and setting ComboBox.SelectedItems=colAssuranceStatus, same result.  It tried putting "First(" infront of the colAssuranceStatus, same result.

 

So what does ComboBox.SelectedItems expect ? Its not a string, its not a table, its not a record ?

 

Thanks

 

Nigel

Microsoft dinusc
Microsoft

Re: DefaultSelectedItems not not available when used on a OnSelect Property

Hello Nigel,

I'm sorry for confusing you. SelectedItems is the output property and cannot be set. This is the reason you see it when you press "." as you mentioned in your first message.

Now, DefaultSelectedItems is an input property and it can be set. For this reason, it will not show in the list of properties when you press "."

The rest of my message seems correct ("SelectedItems" should be replaced with "DefaultSelectedItems"). 

Some of the controls properties in PowerApps are bi-directional, which means that those can be set and also can be read (can be accessed on pressing ".").

For your ComboBox card in the form, all you need to do is to set the DefaultSelectedItems. For a new ComboBox instance, those will become your selected items as well so if you submit your form then those values will be stored. If however you select some items manually then those will become selected items and will be stored. If you reset your ComboBox (Reset(ComboBox1)) then the manually selected items will be removed and default selected items will become again selected. 

Please let me know if you have any questions.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

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