cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kldmurshed
Helper I
Helper I

Help for updating SQL table from selected list items

Hi,

How can I update the SQL table below with these selected list values after pressing the submit button?

 

Kldmurshed_2-1600807946924.png

 

Kldmurshed_1-1600807906673.png

Values will be:

MaterialStaus      InspID

-------------------------

      1                      201

      1                      201

      1                      201

 

I spend 4 hours trying to figure out how to solve it.

I've tried ForAll but it keeps creating new records.

 

Your help would be appreciated.

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

I believe the code would be something like the following:

 

ForAll(RenameColumns(ListBox2.SelectedItems,"SerialNumber","SelectedSerialNumber") ,
Patch(MyTable,LookUp(MyTable, SerialNumber = SelectedSerialNumber,
{
MaterialStatus: ddSelectMaterial.Selected.MaterialStatus,
InspID: ddSelectInspector.Selected.InspID
})
)

 

Note that I've used RenameColumns to try to disambiguate between the SerialNumber field name in the table and the SerialNumber in the listbox2 selection.

I've used Patch instead of UpdateIf as UpdateIf is not delegable so is no good if the number of rows in the table exceeds the delegation limit.

View solution in original post

5 REPLIES 5
VijayTailor
Resident Rockstar
Resident Rockstar

Hi,

You can use LIke below.
UpdateIf(Inventory, ProductName = ProductGallery.Selected.ProductName, {UnitsInStock:UnitsInStock-UnitsSold.Value}).

For More Details, Plz find the below URL.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-update-updateif

Hope this will help you to resolve your Issue.

mdevaney
Super User
Super User

@Kldmurshed 

You must use a ComboBox control instead of a Listbox control.  Why?  ListBoxes cannot output multiple selections.  Its really dumb because the user can click multiple selections.  However, Power Apps cannot tell which selections are clicked when there are more than one.  Its a useless control in my humble opinion.

 

From the Official MS documentation
Selected – The data record that represents the selected item. You can only have one default selected item. If you need multiple selected items please use the Combo Box control.

 

 

MS Official Docs on ListBoxes

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-list-box

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

@VijayTailor 

Have you responded to the wrong question?  I do not see any of the column names in your code here...

@mdevaney 

 

The list box can actually works as combo box.

I made a simple test to output the selected items, see the example bleow.

I used flowing code to output the selections: Concat(ListBox2.SelectedItems,SerialNumber,",")

Lets say its a combo, how and whats the code to update the database table

 

 

 

 

Kldmurshed_0-1600824644023.png

 

I believe the code would be something like the following:

 

ForAll(RenameColumns(ListBox2.SelectedItems,"SerialNumber","SelectedSerialNumber") ,
Patch(MyTable,LookUp(MyTable, SerialNumber = SelectedSerialNumber,
{
MaterialStatus: ddSelectMaterial.Selected.MaterialStatus,
InspID: ddSelectInspector.Selected.InspID
})
)

 

Note that I've used RenameColumns to try to disambiguate between the SerialNumber field name in the table and the SerialNumber in the listbox2 selection.

I've used Patch instead of UpdateIf as UpdateIf is not delegable so is no good if the number of rows in the table exceeds the delegation limit.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,590)