cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lukas1
Advocate III
Advocate III

DefaultSelectedItems removes string with items from collection

Hi,

 

I have a list of items stored in a text-field ("Items") in a collection ("MyCollection"): "Item1, Item2, Item 3"

 

In order to show these items in a combobox I first split the text and store the items in a collection:

 

ClearCollect(
    colItems;
    ForAll(
        Split(
            LookUp(
                MyCollection;
                Serialnumber="12345"
            ).Items;
            ","
        );
        {Value: Result}
    )
);;

 

 

In the DefaultSelectedItems-property of my combobox I have:

 

colItems.Value

 

 

When the screen on which the combobox is located is shown, the text-field Items is being emptied. When I remove the code in the DefaultSelectedItems-property, the string in Items remains as intended.

 

Why is the DefaultSelectedItems-property removing content from the collection?

 

Regards

Lukas

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Lukas1 

Your DefaultSelectedItems property (DSI) needs to be a record (or a table of records if multi-select) that matches the record schema of the Items property.

 

I am not sure if your intention is to select all of the items in your combobox, or if you even have multi-select on.  

 

Please consider changing your Items property Formula to the following:

RenameColumns(
    Split(LookUp(MyCollection; Serialnumber="12345").Items; ",");
    "Result"; "Value"
)

 

You now need to supply a Record to the DSI that is based on this table (a single "Value" column table).

 

So, {Value: "Item1"} for example, in the DSI would select Item1 in the combobox.

 

Since I am not sure what your goal is with the selections, I will leave it with that in hope that it provides the information you need.  If not, then please elaborate on what you are trying to select in the control.

 

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

4 REPLIES 4
RandyHayes
Super User
Super User

@Lukas1 

Your DefaultSelectedItems property (DSI) needs to be a record (or a table of records if multi-select) that matches the record schema of the Items property.

 

I am not sure if your intention is to select all of the items in your combobox, or if you even have multi-select on.  

 

Please consider changing your Items property Formula to the following:

RenameColumns(
    Split(LookUp(MyCollection; Serialnumber="12345").Items; ",");
    "Result"; "Value"
)

 

You now need to supply a Record to the DSI that is based on this table (a single "Value" column table).

 

So, {Value: "Item1"} for example, in the DSI would select Item1 in the combobox.

 

Since I am not sure what your goal is with the selections, I will leave it with that in hope that it provides the information you need.  If not, then please elaborate on what you are trying to select in the control.

 

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

Lukas1
Advocate III
Advocate III

@RandyHayes, thanks!

 

The combobox (multiselect) gets its items from another collection. The user can now select one or more items and these selected items are stored in MyCollection (as a comma separated string as decribed above plus a unique identifier, in this case Serialnumber).

 

The user should be able to access the data that was previously stored in MyCollection by selecting a Serialnumber. That's why I would like to use the comma separaetd items in the DSI of the combobox.

RandyHayes
Super User
Super User

@Lukas1 

Just to double check...you marked my last post as a solution, but I am not sure if you have the solution you need now with your last post.

Are you good now or still having an issue?

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@RandyHayes I struggled first but then I realised that all I have to do is to use the term {Value: "Item1"} (as mentioned in your first reply) in a ForAll loop. So yes, I'm good, thanks a lot for your help 🙂

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,651)