cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cayshin
Resolver II
Resolver II

Gallery can't "see" DefaultSelectedItems of a ComboBox if the ComboBox is connected to a datasource

I've searched around for similar questions, but none seemed to apply to my situation.

 

So I have a Form (Form1) generated from a SharePoint list (List1). I'm creating a "Save" feature for this Form1.

"Saving" is done by having a save button that submits the form, but also patches to List1's Status column the value of "Saved" (whereas the real submit button would set that value to "Submitted"). No issues here.

 

To Load, there are a few steps:

1) Clicking the "Load" button performs a LookUp on List1 using unique identifiers (Status = "Saved", 'Created By' = User().FullName, and Type = TYPE_OF_FORM) then collects that row, if it exists, into the collection LastSaved. No issues there.
2) On the various form fields, the fields' Default or DefaultSelectedItems are set to the appropriate column values from the LastSaved collection.

3) The "Load" button then does a ResetForm(Form1) to refresh the form with the now existing values in LastSaved.

 

This works fine for everything except  for ComboBoxes that are both SelectMultiple=true and set to another DataSource.

 

For Example:

- I have a ComboBox1 with a manually set Items list of: ["1", "2", "3", "4", "5"]

DefaultSelectedItems for ComboBox1 is set to: ForAll(Filter(Split(First(LastSaved.Column1).Column1, ","), Len(Trim(Result)) > 0), Result).

When saving, these selected items are stored as a Concated string list to List1's Column1, then Loading splits them back up to repopulate the ComboBox1. ComboBox1 shows all the items in the field. I can set a Gallery to ComboBox1.SelectedItems.Value and the Gallery will properly display all the selected items.

THE ISSUE

- I have a second ComboBox2 with the Items set to Office365Users.SearchUser({top:999}).

 ComboBox2's DefaultSelectedItems is set to: ForAll(Filter(Split(First(LastSaved.Column2).Column2, ","), Len(Trim(Result)) > 0), Result).

When saving, these items are stored as a Concated string list to List1's Column2, then Loading splits them back up to repopulate the ComboBox2. ComboBox2 does then show the items in the field; however, this time when I set a Gallery to ComboBox2.SelectedItems.DisplayName (the saved name matches exactly a name in the datasource), the Gallery shows there are items, but it's all blank. If I then go to ComboBox2's field and select an additional item, that item correctly shows up in the gallery alongside the blanks ones. Even trying to reference ComboBox2.SelectedItems.DisplayName anywhere only returns only Blank results. So even though ComboBox2 is literately displaying items inside the field, it's like they don't actually exist.

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

@Cayshin 

The default items need to come from a combo box data source, so you would use lookup (or similar) to show the selected items.

 

I had a similar issue recently which was solved and this may explain what you need to do?

https://powerusers.microsoft.com/t5/Building-Power-Apps/ComboBox-DefaultSelectedItems-functionality/...

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Cayshin 

The default items need to come from a combo box data source, so you would use lookup (or similar) to show the selected items.

 

I had a similar issue recently which was solved and this may explain what you need to do?

https://powerusers.microsoft.com/t5/Building-Power-Apps/ComboBox-DefaultSelectedItems-functionality/...

Thanks @Anonymous , that worked!

 

Setting ComboBox2's DefaultSelectedItems to Filter(Office365Users.SearchUser({top: 999}).DisplayName, DisplayName in Filter(Split(First(LastSaved.Column2).Column2, ","), Len(Trim(Result)) > 0)) fixed all the issues.

Helpful resources

Announcements
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.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

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