cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ebraga
Helper III
Helper III

Updating a different SQL table using checkboxes

Good Morning,

 

I am new to PowerApps, in my latest app I have two SQL server connections. (one is a table and one is a view)

In my table, there is one field called PickResult which is int datatype. I need to update the values for this field using a submit button. The checkboxes in my gallery pull from a different SQL view than the table I want to update.

If PICK is checked then the PickResult value will become 1, if the FAIL is checked then the PickResult value will be 0. 

It is possible to do this?

Thank you

9 REPLIES 9
eka24
Super User III
Super User III

On the OnCheck of the Pick;

Patch(Datasource, ThisItem,
{PickResult: Value (Lable1.Text)+1})

 

On the OnCheck of the Fail;

Patch(Datasource, ThisItem,
{PickResult: Value (Lable1.Text)-1})

 

Change label1 to the actual name of the label inside the Gallery

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

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

The SQL view I'm pulling into the gallery does not have the column that I need to update in my SQL table. I want the check boxes to be able to push the updates into the 'PickResults' column with either a 1 or  0.

haroldbk_msft
Community Support
Community Support

if there is only a single choice you may want to use a Radio button. Checkboxes allow for multiple selections.

Assume you have a Radiobutton controls with the items property this:  ["Pick","Fail"]

Then in the update property of the Picklist Fields you could use this logic

If(Radio1.Selected.Value="Pick",1,0)

 

I have made it so users can only select one check box at a time. . The idea is that after the user checks off each of line items with either pick or fail, they would click on the button which would then update the SQL table. 

 

 

ebraga_0-1598459559905.png

 

eka24
Super User III
Super User III

Did you try the formula. Is the issue Resolved?

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

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

I tried the formula and the issue did not resolve. The gallery (the SQL view)  and the table that I want to update do not have the same columns (or 'label') names. I'm looking to update all the check box data to the SQL table at once instead of invidually. Please refer to the other comments I have posted here. Thank you

I have connected a gallery to a SQL View and the coding is very much simplified, but it shows how this can be done.

haroldbk_msft_0-1598479842390.png

the OnCheck property of the Checkboxes looks like this

UpdateContext({varPick:1});
Collect(colResults,{BusEntID:ThisItem.BusinessEntityID,PickResult:varPick,LastName:ThisItem.LastName})

After all the selections are completed there is a Submit button to save the values in the collection to a  SQL table

ForAll(colResults,Patch('[dbo].[Results]', Defaults( '[dbo].[Results]'),{BusEntID:BusEntID,LastName:LastName,PickResult:PickResult}))

Thank you a bunch, this helped a lot. My only question is, how can I make it so the items that have been updated to the SQL table to be removed from the collection?

You can change the expression to lookup to the expressions

ForAll(colResults,Patch('[dbo].[Results]', LookUp('[dbo].[Results]',BusEntID=BusEntID) ,{BusEntID:BusEntID,LastName:LastName,PickResult:PickResult}))

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,319)