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

How do I set a Combo Box's default items to a string from a SharePoint text field?

I have a Combo Box pulling from a SharePoint list. When items are selected from the Combo Box, the IDs for the items are loaded into a SharePoint text field called "Categories" via a CONCAT function that loads as text into an Edit Form. The output is currently a string like the following: 1;2;3

 

I want to set the default selected item/items for the Combo Box to be whatever the contents are of the Categories text field in the SP list for the current gallery item. So, if the string is 1;2;3, I would like to have the SharePoint list items with the IDs of 1, 2, and 3 selected in the Combo Box.

 

Any help would be profoundly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: How do I set a Combo Box's default items to a string from a SharePoint text field?

@pwrappr01 

Categories is a text field and we can reference it like this inside a form

ThisItem.Categories

 

We need to convert the text string into a single column table of values for use in a FILTER function.  For example if we have this text string...

1;2;3

 

...the SPLIT function can be used to change the data type to Table... 

Split(ThisItem.Categories,";")

 

...and the result will look like this.

[1,2,3]

 

With this knowledge we can combined the SPLIT technique we just used with FILTER to look IN the dataset and retrieve the desired records.  From what I understand category is actually a reference to ID in another table.  Put this code in the DefaultSelectedItems of your ComboBox.

Filter(
    your_datasource_name,
    ID in Split(ThisItem.Categories,";")
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

6 REPLIES 6
Highlighted
Super User III
Super User III

Re: How do I set a Combo Box's default items to a string from a SharePoint text field?

@pwrappr01 

Categories is a text field and we can reference it like this inside a form

ThisItem.Categories

 

We need to convert the text string into a single column table of values for use in a FILTER function.  For example if we have this text string...

1;2;3

 

...the SPLIT function can be used to change the data type to Table... 

Split(ThisItem.Categories,";")

 

...and the result will look like this.

[1,2,3]

 

With this knowledge we can combined the SPLIT technique we just used with FILTER to look IN the dataset and retrieve the desired records.  From what I understand category is actually a reference to ID in another table.  Put this code in the DefaultSelectedItems of your ComboBox.

Filter(
    your_datasource_name,
    ID in Split(ThisItem.Categories,";")
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Highlighted
Super User III
Super User III

Re: How do I set a Combo Box's default items to a string from a SharePoint text field?

@pwrappr01 

Did my post answer your question?

Highlighted
Helper V
Helper V

Re: How do I set a Combo Box's default items to a string from a SharePoint text field?

@mdevaney, my apologies. My schedule has not yet allowed me to test out your solution. I imagine it will as it makes sense in terms of how Power Apps understands the data and data type. I will test when I can and post back.

 

Thanks for taking the time to propose it.

Highlighted
Super User III
Super User III

Re: How do I set a Combo Box's default items to a string from a SharePoint text field?

@pwrappr01 

Sounds good to me.  Just wanted to make sure the response was helpful.

Highlighted
Helper V
Helper V

Re: How do I set a Combo Box's default items to a string from a SharePoint text field?

@mdevaney , this worked perfectly. Now I just have to figure out how to ensure the default selected items value gets cleared when I click to clear the filter. I imagine I will need to variablize the code you provided.

Highlighted
Super User III
Super User III

Re: How do I set a Combo Box's default items to a string from a SharePoint text field?

@pwrappr01 

Yes you would have to variabilize it.  I think you've made up a new word here.  I like it!

 

Put this code in the OnVisible property of your screen.  Also put this same code in the OnHidden property of the screen.

Set(clearComboBox,false)

 

Change the DefaultSelectedItems to this code

If(
    clearComboBox=true,
    Blank(),
    Filter(
        your_datasource_name,
        ID in Split(ThisItem.Categories,";")
    )
)

 

Finally, include this code in your button to clear the form

Reset(ComboBox1);
Set(clearComboBox,true);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,354)