cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

5 REPLIES 5
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
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.
SimonJa
Level: Power Up

Re: Use timer offline

Hi @v-xida-msft,

 

Thank you for your answer.

 

I will try it with this method.

 

Would it be possible to use variables to store the time in them?

 

Regards Simon

Fotord
Level: Powered On

Re: Use timer offline

I would try and store the information in case the app is closed or the phone shuts down due to battery loss.
It seems it can be done locally. 

Build app with offline capabilities
Functions load- and save data

CharlesStar
Level: Powered On

Re: Use timer offline

Hi, I have a similar problem here. 

 

I have a timer with a duration of 1sec and a restart fucntion enable. Each loop multiply the time (1 sec) per the number of people working on the job. This gives me the man.hours count for the job. As there is people that will get in and out of the job, I simply tap ''+'' or ''-'' to adjuste the number of employe during the job. 

 

Is there a way to make its work this this proposition? Is there a code we can change to enable powerapps even when the cell is locked i.e. like the timer on the cellphone?

 

Best Regards

 

Charles