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 III
Super User III

@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

View solution in original post

4 REPLIES 4
RandyHayes
Super User III
Super User III

@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

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 III
Super User III

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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (25,462)