cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Aschwinb
Level: Powered On

Patch Timestamp button

0
 

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 an addiction 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'

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Patch Timestamp button

Hi @Aschwinb ,

Do you want to add a Timestamp value to the StartTime column and StopTime column of a specific "TEST"?

 

Based on the formula that you mentioned, I think there is something wrong with it. The First(Filter(Planning, StartTime = "")) formula would return the first record whose StartTime is "" regardless of which "TEST" you select in your Gallery.

 

I have made a test on my side, please consider modify your formula as below:

Set the OnStart property of the "Start" button to following:

Patch(
Planning,
LookUp(Planning, ShipName = Gallery1.Selected.ShipName), /* <-- Gallery1 represents the Gallery control within your app */
{
StartTime: Text(Now())
}
)

Or

Patch(
Planning,
Gallery1.Selected, /* <-- Gallery1 represents the Gallery control within your app */
{
StartTime: Text(Now())
}
)

 

Set the OnStart property of the "Stop" button to following:

Patch(
Planning,
LookUp(Planning, ShipName = Gallery1.Selected.ShipName), /* <-- Gallery1 represents the Gallery control within your app */
{
StopTime: Text(Now())
}
)

Or

Patch(
Planning,
Gallery1.Selected, /* <-- Gallery1 represents the Gallery control within your app */
{
StopTime: Text(Now())
}
)

Note: I assume that the Gallery control (Gallery1) within your app is connected to your Planning Excel table.

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 REPLIES 5
geneZebra
Level 8

Re: Patch Timestamp button

Is it possible the look up is failing to find the record? As a test, try a different value or search condition in the look up. Also if you are looking to add a new row, replace the lookup with the Defaults() function.

 

you also can call the Errors() function to see if it is not blank after the patch. If so, look at the message col of the table it returns.  Notify("Error saving "&Concat(Errors(MyTable),"("&Error&")"& Message &", "))

Aschwinb
Level: Powered On

Re: Patch Timestamp button

@geneZebra Hi, thanks for replying!!

 

I found why the start button didn't add a timestamp to my records, the reason was because my excel file was still opened...

Now have another crucial problem; 

When I click on TEST4 for example, I get to the next 'page', if I click on 'start', it doesn't add a timestamp to TEST4 but to the next one in the row, starting from above (in this case TEST2).

How can I link the timestamp to the right 'TEST' (in my case)? I want the timestamp to be uniquelly linked to the variabele.

Are the pictures clear enough?

Thanks in advance!


Schermafbeelding 2019-06-27 om 15.52.59.pngSchermafbeelding 2019-06-27 om 15.53.11.pngSchermafbeelding 2019-06-27 om 15.53.41.png

Community Support Team
Community Support Team

Re: Patch Timestamp button

Hi @Aschwinb ,

Do you want to add a Timestamp value to the StartTime column and StopTime column of a specific "TEST"?

 

Based on the formula that you mentioned, I think there is something wrong with it. The First(Filter(Planning, StartTime = "")) formula would return the first record whose StartTime is "" regardless of which "TEST" you select in your Gallery.

 

I have made a test on my side, please consider modify your formula as below:

Set the OnStart property of the "Start" button to following:

Patch(
Planning,
LookUp(Planning, ShipName = Gallery1.Selected.ShipName), /* <-- Gallery1 represents the Gallery control within your app */
{
StartTime: Text(Now())
}
)

Or

Patch(
Planning,
Gallery1.Selected, /* <-- Gallery1 represents the Gallery control within your app */
{
StartTime: Text(Now())
}
)

 

Set the OnStart property of the "Stop" button to following:

Patch(
Planning,
LookUp(Planning, ShipName = Gallery1.Selected.ShipName), /* <-- Gallery1 represents the Gallery control within your app */
{
StopTime: Text(Now())
}
)

Or

Patch(
Planning,
Gallery1.Selected, /* <-- Gallery1 represents the Gallery control within your app */
{
StopTime: Text(Now())
}
)

Note: I assume that the Gallery control (Gallery1) within your app is connected to your Planning Excel table.

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Aschwinb
Level: Powered On

Re: Patch Timestamp button

Hi!

I really appreciate your help!

I since my buttons are located on the second (detailed) screen, I don't have the option 'Onstart' for a property, also no 'Onvisible is available', only 'OnSelect' is available for me in the detailed second screen.

I think if that problem is solved, it should work!

Schermafbeelding 2019-06-28 om 10.24.57.pngSchermafbeelding 2019-06-28 om 10.25.08.pngSchermafbeelding 2019-06-28 om 10.25.19.pngSchermafbeelding 2019-06-28 om 10.25.27.pngSchermafbeelding 2019-06-28 om 10.25.34.png

Aschwinb
Level: Powered On

Re: Patch Timestamp button

Hi @v-xida-msft 

I really appreciate your help!

I since my buttons are located on the second (detailed) screen, I don't have the option 'Onstart' for a property, also no 'Onvisible is available', only 'OnSelect' is available for me in the detailed second screen.

I think if that problem is solved, it should work!

Schermafbeelding 2019-06-28 om 10.24.57.pngSchermafbeelding 2019-06-28 om 10.25.08.pngSchermafbeelding 2019-06-28 om 10.25.19.pngSchermafbeelding 2019-06-28 om 10.25.27.pngSchermafbeelding 2019-06-28 om 10.25.34.png

Helpful resources

Announcements
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

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 45 members 4,982 guests
Please welcome our newest community members: