Hi, I have a problem with the time tracking application that I want to implement in my company.
The purpose of this app as the name suggests is to log in and out each user and get a total of hours spent logged in. My database is in a SharePoint list.
The Sharepoint list is called "Project Time Records".
Fields:
Title: automatically pulls the users' emails as it is synchronized with the organization.
Start Time: Type Date and time is the start of the clocking.
End Time: Type Date and time is the end of the clocking.
Time Spent: It makes a total count of minutes that someone has been connected. Inside the application I have a converter that changes it from minutes to hours and minutes.
I have two main buttons: ButonStart (who is in charge of starting the time control) and ButonEnd (who finishes it) I also have fields like active session that is a field of yes or no where it warns if you have started the control or not.
Every time I hit ButonStart or ButonEnd it is disabled until the other has not been selected. To
avoid false registrations or user errors.
The problem is that when I refresh the browser page (I don't want to implement this tool in Microsoft Teams) it re-enables all the buttons and the record ends up as incomplete. Is there any way to be able to keep the state of the buttons despite refreshing the page, as I find it a bad idea that a user can close or refresh the browser window unintentionally and the record he/she has made remains as incomplete.
ButonStart:
Set(
varNewItem;
Patch(
'Project Time Records';
Defaults('Project Time Records');
{
Title: User().Email;
Project: DataCardValue3_1.Selected;
'Start Time': Now();
'Active Session': true
}
)
);;
Set(
StartTime;
Now()
)
ButonEnd:
Set(
varNewItem;
Patch(
'Project Time Records';
LookUp(
'Project Time Records';
varNewItem.ID = ID
);
{
'End Time': Now();
'Time Spent': DateDiff(
varNewItem.'Start Time';
Now();
TimeUnit.Minutes
);
'Active Session': false
}
)
);;
And in the Onstart rule of the App
If(
varNewItem.'Active Session' = true;
DisplayMode.Disabled;
DisplayMode.Edit
);;
Set(
varButtonStartActive;
false
);;
I have used collections, global variables... but nothing seems to work or I am told that it is only supported in mobile version and my goal is a browser window to force the user to use their computer. Any help would be great. @RandyHayes @phipps0218 @WarrenBelz @developerAJ @Ethan_R @Amik
Hi @Ronnystar ,
Use the Code on your OnVisible within screen property if OnStart doesn't works:
Set(SessionData;
First(
Sort(
Filter(
'Project Time Records';
DateValue(DateCreated) = Today() &&
Title = User().Email
);
DateCreated;
SortOrder.Descending;
)
).'Active Session'
);
Set(ButtonEnabled; IsBlank(SessionData));
Hope this helps
Hi @Ethan_R
Hello again, unfortunately I get the message that these functions are not supported by powerapps when I run it. so I have started to think a little and if in the onstart rule I make an "IF" that when the field activate session that is a field of yes or no take information from the field of today's date and the last record to start the application and so when the page is refreshed start in the variable onstart the function and disable the button thanks to the if function. but the codes I provide are not quite correct, could you help me?
My code:
Set(ButtonEnabled; Not(First(Sort(Filter('Project Time Records'; DateValue(DateCreated) = Today()); DateCreated; Descending)).'Active Session')) but not works.
Hi @Ronnystar ,
You can play around by testing this experimental feature.
This is usually used for Offline capabilities also the documentation has steps to achieve it.
If this helps in your situation.
Hope this maintains data integrity and keep your data consistent.
Hi, unfortunately it didn't work for me. I have seen that there is an option in powerapps to enable the save data, load data and clear data functions in the web player. I want to use the load data function to load the data already completed that day from the user, is it possible? 😕
Hi @ronnyestrella ,
I can suggest some changes if it helps you in this scenario as I never crossed such use-case:
1. When you start the App (OnStart) simply get today's record and see if there's already a Checked-in entry based on logged in user
=> If yes, set variable containing the Record or Record ID then reference this variable in your App to control DisplayMode and other functions
Note: This will work if you do not cross 12:00 AM (next day), if you do then change the logic to find Checkin data but doesn't contain check-out or last 2 records from logged in user.
2. To let users exit app or exit and log-out from the account: You can use Exit() function
=> Exit() to close App and Exit(true) to Sign-out the app
3. Restriction in device usage
=> You can use Host properties that is recently introduced or use App Screen property to detect App screen size and perform logic accordingly
Hope this helps