cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
UB400
Kudo Kingpin
Kudo Kingpin

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

@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
irinak
Power Apps
Power Apps

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

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.

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

 

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

Helpful resources

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

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,762)