Hi all,
I've got a list box which lists food items such as "Milk", "Cheese" etc (about 20 items)
In a SQL table I have 3 columns, the food name, the shop and the price. I want it so that when users pick any number of the food items from the list box, then hit a button it sends each of the selected values through as seperate rows to the SQL table.
I've tried just picking out the 'Selected' and it only ever passes through the item which is selected lowest in the list. If I use a 'forall' it will add the number of rows I need, but repeat the same food item for each one as opposed to all of the selected items.
I've also tried a flow but no luck - I'm struggling to find the syntax to say "Pass through the selected values each on their own row"
Any help?
Solved! Go to Solution.
Hi @thewake,
Could you please share more information about the source of the ListBox control?
and Which data do you want to be stored in the SQL Table?
Further, could you please also share a reference of the forall formula?
Also, please make sure you have the ListBox MultiSelection (SelectMultiple property) enabled.
If you would like to save the selected items in ListBox to the food name column of the SQL table, then the formula of OnSelect property of a Button control should be as below:
ForAll(ListBox1.SelectedItems.Value,Patch('[dbo].[Foods]',Defaults('[dbo].[Foods]'),{foodName:Value})))
Note: ‘[dbo].[Foods]’ is a SQL table. The Value in above formula represents the each item of selected items of ListBox control.
Adding some reference:
Regards,
Michael
Have a look at this post: https://powerusers.microsoft.com/t5/PowerApps-Forum/Listbox-MultiSelect-Values/td-p/17709
Can you show your code that dosen't work?
Hi @thewake,
Could you please share more information about the source of the ListBox control?
and Which data do you want to be stored in the SQL Table?
Further, could you please also share a reference of the forall formula?
Also, please make sure you have the ListBox MultiSelection (SelectMultiple property) enabled.
If you would like to save the selected items in ListBox to the food name column of the SQL table, then the formula of OnSelect property of a Button control should be as below:
ForAll(ListBox1.SelectedItems.Value,Patch('[dbo].[Foods]',Defaults('[dbo].[Foods]'),{foodName:Value})))
Note: ‘[dbo].[Foods]’ is a SQL table. The Value in above formula represents the each item of selected items of ListBox control.
Adding some reference:
Regards,
Michael
That worked perfectly. I just didn't have the syntax right. Thanks for the example
LISTBOX DEFAULT SELECT ALL
ComboBox with multi select
Items: Distinct(Filter(Product,Name.Id=Dropdown.Selected.ID),Title)
ListBox
Items: Distinct(Filter(product,Title in Listbox.SelectedItems),Description)
Default:LookUp(Product,Title in listbox.SelectedItems.Result,Description)
textInput: Concat(ADDescription.SelectedItems,Result&",")
while using this scenario, Its working when there is only one item in the combobox and if we select it the description is selected default and added to the textbox
But, when we select multiple items in the combobox, on description it shows both descriptions are selected but its only populating one description on top of the list.
Can you help me with were i'm messing with the formula.
Thanks in advance.
MK
LISTBOX DEFAULT SELECT ALL
ComboBox with multi select
Items: Distinct(Filter(Product,Name.Id=Dropdown.Selected.ID),Title)
ListBox
Items: Distinct(Filter(product,Title in Listbox.SelectedItems),Description)
Default:LookUp(Product,Title in listbox.SelectedItems.Result,Description)
textInput: Concat(ADDescription.SelectedItems,Result&",")
while using this scenario, Its working when there is only one item in the combobox and if we select it the description is selected default and added to the textbox
But, when we select multiple items in the combobox, on description it shows both descriptions are selected but its only populating one description on top of the list.
Can you help me with were i'm messing with the formula.
Thanks in advance.
MK