else }}
post-thumb

Power App for Time Sheeting

Community Sample Timesheet App

This blog explains how I created a time sheet app in Power Apps. The app is made up of 3 core components

  • Dataverse – Where all the data is stored
  • Model Driven App – Manage the Timesheet administration. e.g. Entering new projects
  • Canvas App – Where each user enters their time against a project

Solution (Package)

The easiest and most efficient way to manage or the components is to create a Solution (Package). The Timesheet App Solution is composed of the following:

Solution Package Components

If you are going to modify the app you should also add any additional components to this Solution.

Timesheet Administration - Model Driven App

The Model Driven App has 2 Tables (Projects and Timesheets). Each with a form and a view.

Solution Package Components

Timesheet App – Canvas App

The Canvas App has a single Form. The following is where the “magic” happens.

Run initialisation commands on App Start

Solution Package Components

// Sets a variable for the current user. When the user User saves their timesheet it adds their name to the record.
Set(
    currentUser,
    User()
);

//Create a Collection so the Timesheet data can be used. The Filter ensures that only that users timesheets are retrieved.

ClearCollect(
    colTimesheets,
    Filter(
        Timesheets,
        Person = currentUser.FullName
    )
);

//Create a Collection so all the Projects can be used.
ClearCollect(colProjects,{new_name: Blank()});
Collect(colProjects,Projects);

//Validation to ensure number of hours entered are within range.
Set(
    varHoursEntryValidation,
    false
);

Take action when Save Button is selected

Solution Package Components

//Patch (Save) Timesheet Record to the Timesheet Dataverse Table
Patch(
    Timesheets,
    {
        'Date Worked': DateWorked_DatePicker.SelectedDate,
        Project: Project_ComboBox.Selected.Name,
        'Hours Worked': Value(HoursWorked_TextInput.Text),
        Person: currentUser.FullName,
        Comments: Comments_TextInput.Text
    }
);
//Refresh the Timesheet collection with the new saved record.
ClearCollect(
    colTimesheets,
    Filter(
        Timesheets,
        Person = currentUser.FullName
    )
);

Only enable Save Button if data entry is valid

Solution Package Components

//Enable button if Hours Worked in valid range
If(
    Or(
        Value(HoursWorked_TextInput.Text) <= 0,
        Value(HoursWorked_TextInput.Text) >24,
        Project_ComboBox.Selected.Name = Blank()
    ),
    Disabled,
    Edit
)