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

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.
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!
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.
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!
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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,940)