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

Use timer offline

Is it possible to use a timer when the app is closed? I would need it to record the workingtime of the employees. If I start the timer and lock my phone the timer pause and starts again when I unlock my phone and open the powerapp.

Is it possible that the timer runs even if the app is closed or the phone is locked?

Regards Simon

Fotord
Level: Powered On

Re: Use timer offline

Perhaps you could store the timestamp instead and subtract it from the logout time to get the hours?

Community Support Team Rank
Community Support Team

Re: Use timer offline

Hi @SimonJa,

Do you want to still use Timer control within your app when your app is closed or your phone screen is locked?

If you want to still use Timer control within your app when your app is closed or your phone screen is locked, I afraid that there is no way to achieve your needs in PowerApps currently.

When you lock your phone screen, your app would go into sleep state, all controls within your app would be paused. When you close your app, all controls functionality within your app would also be closed.

 

As an alternative solution, you could consider take a try to store the start time when the employee starts working and the employee name into your data source using the following formula:

Patch(
        'YourDataSource',
         Defaults('YourDataSource'),
         {
           EmployeeName: "A specific employee name",
           StartTime: Now()
         }
)

Then when you want to calculate the working time for this employee, you could take a try with the following formula:

DateDiff(
         LookUp('YourDataSource', EmployeeName = "A specific employee name", StartTime), /* <-- retrieve the Start Time value for the specific employee name */
         Now(),
         Hours
)

Note: The EmployeeName represents the column in your data source to store the employee name, the StartTime represents the Date column to store the start time when employee starts working.

More details about the Patch function, DateDiff function and LookUp function, please check the following article:

Patch function

LookUp function

DateDiff function

 

Best regards,

Kris

 

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.