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

6 REPLIES 6
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.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,357)