cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KMI-Keith
Level: Powered On

Using a button, how do i set a fields value to then send to SQL?

I am trying to create a form that sends our floor employees daily progress reports to our current SQL DB. I have no problem sending the Job and ID info etc. as that is easy, I cannot for the life of me figure out how to create a button to set the field with the current time in a format of hh:mm:ss. I am trying to avoid them typing in 00:00:00 as I can see the nightmare data I will receive. We use this to keep track of job costs but are currently paying someone to enter hundreds of rows of this data into the SQL DB each week and dont know what is going on with a Job in realtime.

 

Any solution would be appreciated!

 

Thanks,

Keith

1 ACCEPTED SOLUTION

Accepted Solutions
KMI-Keith
Level: Powered On

Re: Using a button, how do i set a fields value to then send to SQL?

@AndyPennell Thank you for the reply!

I have this part figured out, I am just new to PowerApps and dont know what to do with this.

 

So far I have tried:

 

Adding 

Text(Now(),"hh:mm:ss")

as the default to the field.

 

 

Creating a Button and in the OnSelect I have

UpdateContext( { StarTime: Text(Now(), "hh:mm:ss") } )

Which doesnt give me any errors and I figured out this just creates a Variable with the correct ouput but I dont know how to get it into the SQL Column on the form so that I can submit the whole row of data.

 

 

I was thinking of the Patch function but I believe that wants an item in the DB and since I havent pushed the row there yet that wouldnt work.

 

EDIT: So this actually will work, what I wasnt understanding was that when you use UpdateContext function, it set a Variables field named StartTime, I dont believe it can set an actual field. So I set my StartTime field's Default value to the Variable StartTime that was created with the UpdateContext function. This worked perfectly and I learned about Variables and how they can be useful!

 

Thanks again for the help!

 

Regards,

Keith

View solution in original post

2 REPLIES 2
Power Apps Staff AndyPennell
Power Apps Staff

Re: Using a button, how do i set a fields value to then send to SQL?

Text(Now(),"hh:mm:ss")
KMI-Keith
Level: Powered On

Re: Using a button, how do i set a fields value to then send to SQL?

@AndyPennell Thank you for the reply!

I have this part figured out, I am just new to PowerApps and dont know what to do with this.

 

So far I have tried:

 

Adding 

Text(Now(),"hh:mm:ss")

as the default to the field.

 

 

Creating a Button and in the OnSelect I have

UpdateContext( { StarTime: Text(Now(), "hh:mm:ss") } )

Which doesnt give me any errors and I figured out this just creates a Variable with the correct ouput but I dont know how to get it into the SQL Column on the form so that I can submit the whole row of data.

 

 

I was thinking of the Patch function but I believe that wants an item in the DB and since I havent pushed the row there yet that wouldnt work.

 

EDIT: So this actually will work, what I wasnt understanding was that when you use UpdateContext function, it set a Variables field named StartTime, I dont believe it can set an actual field. So I set my StartTime field's Default value to the Variable StartTime that was created with the UpdateContext function. This worked perfectly and I learned about Variables and how they can be useful!

 

Thanks again for the help!

 

Regards,

Keith

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,870)