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

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

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

 

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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (52,746)