cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
samvanroy
Level: Power Up

Sending data to a SQL server with a button push or checkbox in a table

Hi,

 

I created a table with a filter in powerapps based on a SQL server. 

Per row, I want a feature where I can select "Seen". This can be in the form of a checkbox/ button or whatever.

 

In other words, I need to add some sort of checkbox to my Powerapps table and when checked, it needs to push this data into my SQL database. 

 

Does somebody have an idea on how to do this? Smiley Happy 

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Sending data to a SQL server with a button push or checkbox in a table

Hi @samvanroy 

The absence of the Seen column in your table would explain the error.

For true/false or yes/no values in SQL Server, I would recommend the bit data type.

View solution in original post

7 REPLIES 7
Highlighted
Super User
Super User

Re: Sending data to a SQL server with a button push or checkbox in a table

Hi @samvanroy 

The Patch function enables you to update a single record.

A typical way to build this type of functionality is to use a gallery control and to set the Items property to your data source. You can then add a button into the item template of the gallery and set the OnSelect property to something like this:

 

Patch('[dbo].[YourSQLDataSource]', 
Gallery1.Selected,
{Seen: true}
)

The first argument defines the datasource, the second the record you want to update, and the third argument defines the field/value that you want to set. Hope that's of some help.

samvanroy
Level: Power Up

Re: Sending data to a SQL server with a button push or checkbox in a table

Hi @timl !

 

Thanks for your answer!

I stuggeling with the Gallery. How exactly can I add a button into the gallery? 
I don't find anything online about customizing the template.

 

Thanks!

Super User
Super User

Re: Sending data to a SQL server with a button push or checkbox in a table

Hi @samvanroy 

If you select the top section of the gallery control, you can use the Insert > Button item to insert a button into the gallery template. You can check that you've done this correctly by looking in the tree view - the new button will appear as a child item beneath your gallery control, as highlighted in the image beneath.

 

image.png

samvanroy
Level: Power Up

Re: Sending data to a SQL server with a button push or checkbox in a table

Hi @timl 

 

Am I doing something wrong? It keeps giving me error messages. When I test the app the checkbox unchecks itselves when I refresh or do some sorting.

Current settings:

Capture.PNG

Super User
Super User

Re: Sending data to a SQL server with a button push or checkbox in a table

Hi @samvanroy 

If you hover the mouse over the squiggly red lines, can you tell us the error message that appears?

Also, can you confirm that the field name in your Job table is called Seen? If so, what is the data type of this field?

samvanroy
Level: Power Up

Re: Sending data to a SQL server with a button push or checkbox in a table

Hey @timl ,

 

The error messages is in Dutch but translated it's:

"The Patch function has some false arguments."

 

And ofcourse... I don't have a column in my table yet for the checkbox... 

What do you recommend as a data type?

Thanks!

Super User
Super User

Re: Sending data to a SQL server with a button push or checkbox in a table

Hi @samvanroy 

The absence of the Seen column in your table would explain the error.

For true/false or yes/no values in SQL Server, I would recommend the bit data type.

View solution in original post

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Demo Extravaganza Championship Voting Open

Voting Ends: October 30, 2019!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 192 members 5,050 guests
Please welcome our newest community members: