cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JamesFox
Frequent Visitor

Listbox in Power Apps Form Writing Multiple Values to SharePoint List

Hi there,

 

I have a listbox in a Power Apps Form that I would like to use to allow users to select multiple items and have them write to a single field in a SharePoint list, perhaps separated by commas or semicolons. 

 

I've been able to create the listbox and have it populate from another SharePoint list, and I've amended the Update field of the datacard as follows (where Title is the name of the field that populates the listbox): 

DataCardValue2.SelectedItemsText.Title

 

When I submit the form with multiple items selected in the listbox, there are no runtime errors, but the multiple items do not write to the corresponding SharePoint list. The target column is set as Single Line of Text.

The question is, do I have the wrong syntax in the Update field, or is the SharePoint list column type set up incorrectly to receive the data? 

 

Many thanks in advance for any assistance that may be provided.

 

Best,

James.

 

Annotation 2020-02-27 151728.png

1 ACCEPTED SOLUTION

Accepted Solutions

In a form, every field is represented by a card. If I understood your case correctly then you would like to take multiple selected values from a ListBox and save them as a single value in a list field of type "Single lie of Text". If so and then in a form that is bound to the list you want to save to, you should be able to add a card for that Single lie of Text field. You will most likely end up with a TextInput control there, like in the attached picture.

 

Note the card's Update property. Now you can unlock the card from Advanced Panel, remove the TextInput control (DataCardValue10)  and replace it with ListBox control (ListBox1 for example). After this you can set the following formula into the card's Update property field:

Concat(ListBox1.SelectedItems, Title&",")
This will essentially join all the values (Titles) into a single comma separated field. Note that an extra coma will be present at the end (you can remove it with another function if you want) and that the formula assumes that you're interested in saving the "Title" field of the selected item. Hope this helps.

View solution in original post

8 REPLIES 8
dinusc
Microsoft
Microsoft

Hello @JamesFox ,

Please try to use the "Concat" function in order to convert your list of multiple items into a comma separated string:

Concat(DataCardValue2.SelectedItemsText, Title& ", " )

Hi there @dinusc ,

 

Many thanks for your assistance. Could I just confirm where I need to enter the concat function? When I try to enter it into the Update field of DataCard2 it won't run as it expects a Table as the first parameter, not DataCardValue2.

 

Best,
James.

 

Annotation 2020-02-27 151728.png

In a form, every field is represented by a card. If I understood your case correctly then you would like to take multiple selected values from a ListBox and save them as a single value in a list field of type "Single lie of Text". If so and then in a form that is bound to the list you want to save to, you should be able to add a card for that Single lie of Text field. You will most likely end up with a TextInput control there, like in the attached picture.

 

Note the card's Update property. Now you can unlock the card from Advanced Panel, remove the TextInput control (DataCardValue10)  and replace it with ListBox control (ListBox1 for example). After this you can set the following formula into the card's Update property field:

Concat(ListBox1.SelectedItems, Title&",")
This will essentially join all the values (Titles) into a single comma separated field. Note that an extra coma will be present at the end (you can remove it with another function if you want) and that the formula assumes that you're interested in saving the "Title" field of the selected item. Hope this helps.

Hi there @dinusc,

 

Yes, that worked perfectly - thank you very much.

 

Best,

 

James.

Thanks, But what does Title refer to in this formula.

I tried Concat(ListBox1.SelectedItems, ",") and it just stores , instead of any values.

Dunc
Frequent Visitor

Title probably refers to the actual field name in the sharepoint list. 

 

SharePoint lists by default have a Title field. You can rename it in SharePoint, but in the background, it still calls it 'Title'. The way to see exactly what SharePoint calls a field is when viewing a List, click on the cog, top right corner, and go to List Settings.

 

You will see a list of all column names. If you renamed the default Title field to, say, 'Bananas', then click on 'Bananas' field in the list. You will move to a field edit screen, but look at the address bar/URL....the very last part of that will show the actual name SharePoint uses.

 

If this doesn't make sense, let me know.

In my case, I use a collection of names to populate a listbox.  The method stated saves the multiple selections in my associated list as expected. The issue I have is I need each Listbox to highlight the names stored in its associated list field for the selected record, if the field contains data...Not having luck with this.

 

Any ideas?

JacksonTeo
Frequent Visitor

Hello, it works when adding a new record. How about if I'm using the same form with the same list box to edit a record? The selected Items are not highlighted in the list box. Please help.

Helpful resources

Top Solution Authors
Top Kudoed Authors
Users online (4,027)