cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
UB400
Level 10

ListBox

I would like to use a ListBox to collect a selection of items and then save them to a SharePoint List. I understand that I can use Concat to convert the selected items to Text to save them to the List.

 

If the User needs to edit the selected items in the future, is there a way to read the record from the table and then highlight the selected items in the ListBox control?

 

I'm not using Form Controls, simply using Patch to save the record to the SharePoint List.

 

I now need to be able to allow the User to edit the values.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
UB400
Level 10

Re: ListBox

@irinak thank you for getting back to me. I found the answer to using Collect to post to a Datasource in this link

 

https://powerusers.microsoft.com/t5/PowerApps-Forum/Collect-with-data-source-not-with-collection/td-...

 

Basically this Code works:

 

Collect(temp,{},{},{});
Collect(datasource,temp)

Thanks again for your help with this. 

View solution in original post

4 REPLIES 4
PowerApps Staff irinak
PowerApps Staff

Re: ListBox

Hi UB400,

 

ListBox supports setting a single default value. Gallery control with checkboxes may work better here.

 

Here is a simple example (without a SharePoint connection)

  1. Initialize a couple of collections – you can do that on Screen1.OnVisible
    ClearCollect(Fruit, "Orange", "Apple", "Pear", "Plum"); ClearCollect(Favorites, "Orange", "Plum")
  2. Add a custom gallery control Gallery1, then add a checkbox control Checkbox1 inside the gallery
  3. Set Gallery1.Items property to Fruit collection
  4. Set Checkbox1 properties as follows:
    1. Text = Value
    2. Default = LookUp(Favorites, ThisItem.Value = Value, true)
    3. OnCheck = Collect(Favorites, ThisItem)
    4. OnUncheck = Remove(Favorites, ThisItem)

The above will add and remove Favorites from the collection. I am attaching a screenshot of what it would look like - you can customize it to fit your app.

 

 GalleryWithCheckboxes.PNG

 

Hope this works for you!

 

Irina

UB400
Level 10

Re: ListBox

Thanks @irinak that is very hepfull.

I referred to the documentation for Collect, to try and understad what the syntax would be to "Collect" to the DataSource (in this case Sharepoint).

 

I tried Collect(Name of SPList,ThisItem)

 

While this did not show any errors in the formula, it does not add the record to the SP list, please advise?

 

Also I have some additional fields that I want to add to the record in SP. Looking at the Collect Documentation, I should be able to us the following syntax

 

Collect(SPList,{FirstName:TextBox1,Email:User()Email,Option:CheckBox1.???})

 

What should be the correct syntax to pass other values from the Screen together with the Text associated with the checkbox?

 

Thanks.

PowerApps Staff irinak
PowerApps Staff

Re: ListBox

Hi UB400,

 

What does your SP list look like?

 

You may want to use a Form control if you are looking to update a record. To see form control in action, try creating an app directly from your SharePoint list. To do that, choose New -> Start with your data -> SharePoint. That will generate an app with 3 screens that will let you view, add and edit items. Here is a reference for the form control: https://powerapps.microsoft.com/en-us/tutorials/control-form-detail/

 

To answer the last question, you can use Checkbox1.Text to get the text or CheckBox1.Value to get the value of the checkbox

 

Best regards, 

Irina

 

Highlighted
UB400
Level 10

Re: ListBox

@irinak thank you for getting back to me. I found the answer to using Collect to post to a Datasource in this link

 

https://powerusers.microsoft.com/t5/PowerApps-Forum/Collect-with-data-source-not-with-collection/td-...

 

Basically this Code works:

 

Collect(temp,{},{},{});
Collect(datasource,temp)

Thanks again for your help with this. 

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,096)