This is a challenging time for businesses as they are trying to operate under new health regulations/policies. Microsoft provides an all inclusive Power Apps solution free for businesses that they can use to effectively record, manage and monitor location readiness, employee health and facilities management. You can visit : https://docs.microsoft.com/en-us/powerapps/sample-apps/return-to-workplace/overview to learn more about this free solution.
This solution includes a mobile app that can be used by employees to get a day pass, lookup facility status, or answer the employee sentiment question. However, this does not include submitting the actual clock in/out times of employees. Since Power Apps are highly customizable, we can add this feature to our existing mobile app with a few changes.
Note that below solution was implemented for a business that had only one facility. Later in this article, I will explain how we can easily configure this for multiple facilities/areas. Here is the final result:
We can break this new feature into 4 parts
Add a new button to the homepage and navigate to a different screen. Since there is only one facility, we can directly set a global variable as DefaultFacility and assign the facility ID that corresponds with the office facility record.
See below example, I have mentioned “Operational Area” as the default facility for clocking in/out. You can see that the GUID in above code and the entity record ID are similar.
2. Create new “Employee Visit” record on clock-in and return the created record
This is a button that patches an “Employee Visit” record to CDS upon submission. Let’s check the button OnSelect code:
In the first line, I am creating a variable ClockIn and setting the value as current date/time.
Next, I am patching a new “Employee Visit” record with the EmployeeID/Name/ Facility and passing ClockIn as the “Start Time” field value in the new record.
I set another global variable as PatchedRec and assign the return record value of the patch query so that it can be used to update clock-out time.
3. Update the end time field of “Employee Visit” record upon selecting “Clock-Out” button
Ok, so far we were able to create an Employee Visit record and return the created record to our canvas app.
Now, we need to add another button for “Clock-Out”. Upon submission, we should be able to get the current time and update the “End Time” of the Employee Visit record.
Here is the button OnSelect code:
First, I am creating ClockOut variable to store current date/time.
Next, I am using the existing “Employee Visit” record using PatchedRec and updating the “End Time” field with ClockOut value.
4. Add UI changes
Once clock-in option is pressed, the button should be hidden as users should not click on clock-in again. Similarly, once clock-out is pressed, it should get hidden and display the clock-in button to create a new visit record.
This can be easily achieved by using custom global variables. Here is an example for clock-in button.
In this example, I am creating 2 variables and define them as below:
When clock in is pressed, ci value becomes false and co value becomes true
Set the Visible attribute of each button with above variables. In this example, I have assigned ci as the value for button visibility
Clock icon was used for added visual flare and the icon color can be changed the same way we change visibility using custom variables.
Clock in button OnSelect action changes the variable clockColor. Similarly, clock out button changes the variable clockColor to a different color
We can assign the Icon Color attribute with this variable so that it changes upon clock in/out.
Ideas for enhancements
This app was created for a business that has only one office facility. It can be extended for multiple facilities by making a small change.
Instead of setting the DefaultFacility variable with direct GUID, we can add a facility dropdown and then assign Dropdown.selected value as DefaultFacility.
This way, users can select the facility and then clock-in/out.
“Return to workplace” is a great solution for any business. With a little bit of configuration and low code, we can add additional functionality to this solution.
Leave a Reply