cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

COMBOBOX Issuess!

When a user selects multiple items from the combox field and submits it, they are able to do that but when they reopen the form to edit it, the selected items disappear and only 1 item is shown.

 

The DefaultSelectedItems value of my combobox is : { Result: Parent.Default }.

 

Please advice.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: COMBOBOX Issuess!

There's nuances to this. When you concatenate the selected items in the combobox, you need to put in logic to place the delimiter for all options except the last. If you Split a string where the semi-colon is behind the last option, you'll get a blank row for the last one.

 

OR, when you use the Split() function to break apart each option, you need to filter out any results that are blank.

Filter(Split(ThisItem.Column,";"),!IsBlank(Result))

This means, "Split up what's in the column each time there is a semi-colon. Then show only the rows where the result is not blank."

View solution in original post

16 REPLIES 16
Highlighted
Power Apps
Power Apps

Re: COMBOBOX Issuess!

Hi @asdeev,

The way DefaultSelectedItems works depends on how you set up the column: is it a field that can take multiple values or just one?

 

We'll need more information about your columns to help out.

 

I made a video on this topic recently:

https://www.youtube.com/watch?v=bwqCEQb3_TM

Highlighted
Helper V
Helper V

Re: COMBOBOX Issuess!

Hi,

 

It takes multiple values and I want all the values to be shown when we go in edit mode of the form.

 

My data is coming from SQL.

 

Thanks for all your time and help. 

Highlighted
Helper V
Helper V

Re: COMBOBOX Issuess!

DefaultSelectedItems property of my combobx is : 

{ Result: Parent.Default }

 

When I tried to set the update property of this card to "ComboBox.SelectedItems" (without quotations) it says " the property expects text values but this rule produces incompatible Table values"

Highlighted
Power Apps
Power Apps

Re: COMBOBOX Issuess!

What type of column are you using in SQL?

Highlighted
Helper V
Helper V

Re: COMBOBOX Issuess!

The column name is "BuildingName" and the Type is nvarchar(255)

Highlighted
Helper V
Helper V

Re: COMBOBOX Issuess!

The column name is "BuildingName" and the Type is nvarchar(255) and in Powerapps I have "Location" as a COMBOBOX and the datatype of location is nvarchar(255) . 

 

The items property of the combobox is:

Distinct(Filter(SortByColumns('[dbo].[SP_Hierarchy]',"BuildingName",Ascending),SiteSubType= "Data Center", Status = "Active"), BuildingName)

Highlighted
Helper V
Helper V

Re: COMBOBOX Issuess!

Also, what should my Patch() look like? When the user chooses multiple options from the combobox will my patch finction be Location: Combox.Selected.Result

 

or should it be concatenating selected items? Please advice.

Highlighted
Power Apps
Power Apps

Re: COMBOBOX Issuess!

SQL is not capable of storing multiple selections in the way you're expecting. The column type you have is expecting a string that has no more than 255 characters. But selections in a combobox make up a table (rows and columns), not a string (think 'cell').

 

There's a couple ways people solve this. One would be to concatenante all the strings from the combobox selection and separate them with a delimiter like a semi-colon. The result of what you save would look something like this:

math; reading; science

This solution would require you to split up that string back into a table later when viewing what is saved. 

 

The other would be to create an additional table where you save the selections and include a column that relates back to the first. This is part of relational tables.

 

But before you proceed, I would suggest retooling how you set up your database structure. @Drrickryp wrote a 3-part series on setting up your database. Here's part 1:

https://powerusers.microsoft.com/t5/PowerApps-Community-Blog/Database-design-and-PowerApps-Step-1-Pl...

 

Note: SharePoint has a column type that can hold multiple selections out of the box as fyi.

Highlighted
Helper V
Helper V

Re: COMBOBOX Issuess!

Thank you!!

I have used the delimiter and it works great!

 

 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

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