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

MS PowerApps timestamp button doesn't work

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

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User
Super User

Re: MS PowerApps timestamp button doesn't work

Hi @Aschwinb 

Could you replace the commas with semi-colons to see if that makes a difference?

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

If not, could you click the red error icon that appears next to the start button and let us know what the error message is?

 

View solution in original post

Super User
Super User

Re: MS PowerApps timestamp button doesn't work

Hi @Aschwinb 

Another way is to store the record that you just updated in variable. If you then click the Start button again, you can modify your formula so that it updates the last updated record, rather than the next record with a blank start time.

In the OnVisible property of your screen, you can initialise a variable called LastUpdatedRecord like so.

Set(LastUpdatedRecord, Blank())

You can then modify your Patch function like so:

Set(LastUpdatedRecord;
    Patch( Planning;
           If(IsBlank(LastUpdatedRecord); 
First(Filter( Planning; StartTime = "" ) );
LastUpdatedRecord
); { StartTime: Text( Now() ) } ) )

View solution in original post

6 REPLIES 6
Highlighted
Super User
Super User

Re: MS PowerApps timestamp button doesn't work

Hi @Aschwinb 

Could you replace the commas with semi-colons to see if that makes a difference?

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

If not, could you click the red error icon that appears next to the start button and let us know what the error message is?

 

View solution in original post

Aschwinb
Level: Powered On

Re: MS PowerApps timestamp button doesn't work

Still doesn't work 😞

this is the error I get: translated: the requested ressource is locked. Serverresponsibility: Can't write file to filesource. file is locked.........


@timl wrote:

Hi @Aschwinb 

Could you replace the commas with semi-colons to see if that makes a difference?

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

If not, could you click the red error icon that appears next to the start button and let us know what the error message is?

 


 

 

Schermafbeelding 2019-06-27 om 14.00.31.png

Super User
Super User

Re: MS PowerApps timestamp button doesn't work

Hi @Aschwinb 

The syntax with semi-colons appears correct because the function names in your formula bar are now coloured correctly.

The 'resource locked' error typically occurs when your Excel file is open somewhere else. To resolve this, I would make sure that the file isn't opened elsewhere, or by another user. Once you're sure this is the case, I would try again.

Aschwinb
Level: Powered On

Re: MS PowerApps timestamp button doesn't work

Ok that was the problem, thank you so much!

Now I have one more problem, when I click 2 times on the start button, it writes a timestamp on the next row of my excel table (which is new 'ship' in my case), while I want every ship to be unique and only have one timestamp.

When I click on 'start' for ship with surveyor A for 2 times, instead of overwriting the time for start, it adds a new timestamp for ship with surveyor B, which I don't want.

 

Schermafbeelding 2019-06-27 om 14.39.44.pngSchermafbeelding 2019-06-27 om 14.39.34.png

Community Support Team
Community Support Team

Re: MS PowerApps timestamp button doesn't work

Hi @Aschwinb ,

I suggest you change your formula about filter data.

Try this formula:

Patch( Planning; ThisItem ; { StartTime: Text( Now() ) } )

The reason why you met the problem is that if you click once the start button, the original item's StartTime field will not be blank. So if you click the start button twice, the patched item will be the next one.

 

Best regards,

Community Support Team _ Phoebe Liu

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Super User
Super User

Re: MS PowerApps timestamp button doesn't work

Hi @Aschwinb 

Another way is to store the record that you just updated in variable. If you then click the Start button again, you can modify your formula so that it updates the last updated record, rather than the next record with a blank start time.

In the OnVisible property of your screen, you can initialise a variable called LastUpdatedRecord like so.

Set(LastUpdatedRecord, Blank())

You can then modify your Patch function like so:

Set(LastUpdatedRecord;
    Patch( Planning;
           If(IsBlank(LastUpdatedRecord); 
First(Filter( Planning; StartTime = "" ) );
LastUpdatedRecord
); { StartTime: Text( Now() ) } ) )

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

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