0
votes

I am trying to make an app where a user can click a button 'start' when he starts an action and 'stop' when he stops an action. Both of these actions should result in adding a timestamp to the record (column in excel file)

the following function is linked to my button 'start':

OnSelect = Patch( Planning, First(Filter( Planning, StartTime = "" ) ), { StartTime: Text( Now() ) } ) 

(Planning is the name of the table in my excel file, StarTime= name of the column in Excel where the timestamp should be added)

When I try the app, clicking the button doesn't result in the addition of the timestamp in my excel file.

link to pictures of powerapps and excel table: https://imgur.com/a/XgQF56y?

What is wrong with my function/code?

Thanks in Advance!!

OnSelect = Patch( Planning, First(Filter( Planning, StartTime = "" ) ), { StartTime: Text( Now() ) } )

I expect the timestamp to be added to the right row and right column (StartTime) in the record (excel file) with table name 'Planning'

3

3 Answers

0
votes

Use variable to capture the start and end time and update the form will be a easy-to-build and better performing method. enter image description here

On the right side, I have an edit form and unlocked the datacards of start and end time. Then the Default of both datacard is set to be variables: start_var and end_var. The two buttons are used to set the current time to each variables, since you are collecting Now() from your image. The final update to the table is still done through the Submit button. This way less patch functions are needed. I can share this example with you.

Happy building!

0
votes

I'd recommend first creating a unique ID column in your Excel file or some other way to determine the exact record to Patch. Then set a variable in PowerApps based on which record the user is editing.

Then try OnSelect:

Patch(tblPlanning,
    LookUp(tblPlanning, uniqueID = varID),
    {startTime: Text( Now() ) } 
)
0
votes

Try this may be you can get solution

Set the end label Defualt = StartLabel.Text + EndLabel.Text

If your name is different use that name. This will add the start time and when the time is ended.