cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TataLili
New Member

Mutli selection in SP list not showing in PowerApps ComboBox when editing

Hello, 

I am struggling with ComboBox since yesterday, found most of my solutions but can't seem to solve this last one. Hope someone will be able to help 🙂

 

I have a SharePoint list with several fields including a Single line of text field called "Competitor Brand". I am using PowerApps to customize this form and make it more efficient.

1. I created a second list in the background listing all competitor brands which I want to offer as choices in my form. This list is called "CompetitorBrands".

2. In PowerApps, I removed the Text input box from the form and replaced by a ComboBox (as I want multiple choices to be unabled).

3. The ComboBox Item Property is: SortByColumns(CompetitorBrands.Title, "Title")

4. The DataCard Update Property is: Left(Concat(ComboBox1.SelectedItems, Title & ", "), Len(Concat(ComboBox1.SelectedItems, Title & ", "))-2)

 

With this configuration I am able to save a new list item and it displays as expected, meaning that if 3 competitors are selected it will report in the SharePoint list as 1, 2, 3

 

My issue comes up when I want to edit this item, the ComboBox shows up empty instead of having choices 1, 2 and 3 selected.

Any idea of how to solve this?

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@TataLili 

If you are working with a Combobox, then you need to set the DefaultSelectedItems (DSI) property to be a table of records that have the EXACT schema of the Items property.  You have not mentioned what your DSI is currently, but without it, you will have nothing selected when you edit a record.

 

If your Datacard Update property is:

With({_d: Concat(ComboBox1.SelectedItems, Title & ", ")}, 
    Left(_d, Len(_d)-2)
)

 

And your Items property is: 

SortByColumns(CompetitorBrands.Title, "Title")

 

AND - Assuming that Title is the ONLY column of interest in your combobox, then you should CHANGE the Items property to:

SortByColumns(CompetitorBrands.Title, "Title").Title

And then Set the DSI property to:

RenameColumns(
    Filter(
        Split(Parent.Default, ", "),
        !IsBlank(Result)
    ),
    "Result", "Title"
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@TataLili 

If you are working with a Combobox, then you need to set the DefaultSelectedItems (DSI) property to be a table of records that have the EXACT schema of the Items property.  You have not mentioned what your DSI is currently, but without it, you will have nothing selected when you edit a record.

 

If your Datacard Update property is:

With({_d: Concat(ComboBox1.SelectedItems, Title & ", ")}, 
    Left(_d, Len(_d)-2)
)

 

And your Items property is: 

SortByColumns(CompetitorBrands.Title, "Title")

 

AND - Assuming that Title is the ONLY column of interest in your combobox, then you should CHANGE the Items property to:

SortByColumns(CompetitorBrands.Title, "Title").Title

And then Set the DSI property to:

RenameColumns(
    Filter(
        Split(Parent.Default, ", "),
        !IsBlank(Result)
    ),
    "Result", "Title"
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
TataLili
New Member

That is exactly what I needed, now it works !! 

I had understood that I had to input something in the DefaultSelectedItems and that in included it  RenameColumns and Split functions but was not able to figure out how to set it up.

 

For my understanding, could you explain what Parent.Default refers to and what the purpose of the filter function is with this !IsBlank(Result) ?

 

Other than this I am accepting your answer as a solution. Thank you! Thank you! Thank you!

RandyHayes
Super User
Super User

@TataLili 

 

DataCards in a form have a Default and an Update property.  These are *highly* important to your form and are used to influence many of the features of a form.

The Default property is sort of the "input" to the datacard.  It is usually set to ThisItem.yourFIeld  So, essentially it is providing the value of the column for the record in the Item property of the form to the datacard.  This should very rarely be changed.  

The Update property of the datacard is the "output" of the datacard that is supplied to the underlying Updates record...which is what is ultimately written to the datasource during a SubmitForm.

The Unsaved property of the form relies on default and the update properties of all of the datacards in the form.  If it senses any difference between the Default and the Update properties of datacards, then the form is considered Unsaved.

 

Controls all belong to parents.  If you add a label to the screen, then the screen is the parent of the label.

If you add a form, the screen is the parent of the form.  If you have a datacard in the form, then the form is the parent of the datacard.  If you have a control in a datacard, then the datacard is the parent of the control.

SO...since the datacard has a Default and an Update property, then any control in the datacard can access those properties by referencing Parent.<property>  In this case, Parent.Default.

 

So in context now...your Default property of your datacard will have the joined string value of your competitor brand and the Default property will be shown as ThisItem.'Competitor Brand'

The Combobox is in the datacard, so we can reference the Default with Parent.Default - we could have also referenced it with yourDataCardName.Default but, using Parent is much easier.

 

As a bonus...the keyword Self is also useful.  It refers to the control itself.  So, for example, the OnSuccess action of the form is where you do actions when a submit is successful.  Many times you want to reference the record that was last submitted.  Thus, the LastSubmit property is a property that represents the last record written successfully.  So, to reference that, you could do yourForm.LastSubmit  OR, since you are in the context of the form, Self.LastSubmit is more generic and doesn't stop your train of thought to recall what your form name is.  

This goes for any control and any property...you can access it within the context of the control with self.

Like if you have a label and set it to look up a status in a record. Then you have a status, let's say "Open".  And now you want the color to be Green if the status is "Open", and Red if it is "Closed".  So, in the Color property of the Label, you can have this formula : Switch(Self.Text, "Open", Green, "Closed", Red, Black)  This is much quicker that repeating the formula or even having to remember the name of the label.

 

NOW...the !IsBlank bit.

When you spilt a text string many times that string might have a trailing separator.  Don't worry about trying to avoid putting it in because you can just filter it out...

If you have a trailing separator, then you will end up with a last record that is empty because there is nothing beyond the trailing separator.  In your scenario with a combobox, this WILL cause the DSI to not work properly (i.e. having a blank record in the DSI table).

So, the purpose of the Filter on the !IsBlank(Result) is just to remove that (or other) empty records from the Split.

 

Hopefully that is all clear and helpful.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,058)