Stage 8 of 17

Stage 8 of 17

Build — Power Apps Canvas App

In this stage you will build the Power Apps canvas app. You will create the app, connect it to the Microsoft Lists data source, build all five screens, add validation, and implement the submit and cancel logic. Every formula is explained — not just shown.

Why Are We Doing This?

Power Apps uses a formula language called Power Fx. It is similar to Excel formulas — each control property has a formula that determines its value or behaviour. Understanding the formula logic is more important than memorising the exact syntax. If you understand what a formula is trying to do, you can adapt it when something changes.

Step 1 — Create the Canvas App

1

Navigate to make.powerapps.com. Sign in with your Microsoft 365 account.

2

Select "+ Create" from the left navigation. Choose "Blank app".

3

Select "Blank canvas app". App name: "Leave Request App". Format: Tablet (this gives more screen space for the form). Select Create.

4

The Power Apps Studio opens. You will see a blank canvas with a properties panel on the right and a formula bar at the top.

5

Save the app immediately: File → Save. This creates the app in your environment. Save frequently throughout the build.

Step 2 — Connect the Data Source

1

In the left panel, select the Data icon (looks like a cylinder or database). Select "+ Add data".

2

Search for "SharePoint". Select the SharePoint connector.

3

Select "Connect directly (cloud services)". Enter the URL of your SharePoint site (the URL you noted in Stage 7). Select Connect.

4

A list of SharePoint lists on that site will appear. Select "Leave Requests". Select Connect.

5

The Leave Requests data source now appears in the Data panel. You can reference it in formulas as "LeaveRequests".

6

Verify the connection: in the formula bar, type "LeaveRequests" and press Enter. If the connection is working, you will see the data source reference without an error.

Beginner Tip

Power Apps uses delegation for large data sources. Delegation means that filtering and sorting is done by SharePoint (the server) rather than by the app (the client). For the Leave Requests list, always use Filter() with delegable functions. The most common non-delegable function is Search() — use Filter() with StartsWith() or the "in" operator instead for large lists.

Step 3 — Build Screen 1: Home

1

Rename the default Screen1: right-click it in the Screens panel and select Rename. Name it "HomeScreen".

2

Add a Rectangle control as the header background. Set Fill to a dark colour (e.g. RGBA(15, 27, 45, 1) for navy). Set Width to Parent.Width, Height to 80, X to 0, Y to 0.

3

Add a Label inside the header. Text: "Leave Request App". Set font size to 20, bold, white text. Position it inside the header rectangle.

4

Add a second Label below the header. Text formula: "Welcome, " & User().FullName. This displays the logged-in user's name from their Microsoft 365 profile.

5

Add a Button. Text: "New Request". OnSelect formula: Navigate(NewRequestScreen, ScreenTransition.Fade). This navigates to the New Request screen when tapped.

6

Add a second Button. Text: "My Requests". OnSelect formula: Navigate(MyRequestsScreen, ScreenTransition.Fade).

7

Add a third Button. Text: "Administration". OnSelect: Navigate(AdminScreen, ScreenTransition.Fade). Visible formula: User().Email in ["admin@contoso.co.uk", "hr@contoso.co.uk"] — replace with your admin email addresses.

8

Add a Label showing pending requests. Text formula: CountIf(LeaveRequests, EmployeeEmail = User().Email && Status = "Submitted") & " pending request(s)". This counts the current user's submitted requests.

HomeScreen — Pending count label Text propertyPower Fx
CountIf( LeaveRequests, EmployeeEmail = User().Email && Status = "Submitted" ) & " pending request(s)"

What this does: CountIf counts the rows in LeaveRequests where both conditions are true: the EmployeeEmail matches the logged-in user's email, AND the Status is Submitted. The & operator concatenates the count with the text string.

Step 4 — Build Screen 2: My Requests

1

Add a new screen. Rename it "MyRequestsScreen".

2

Add a Back button. Text: "← Back". OnSelect: Navigate(HomeScreen, ScreenTransition.Back).

3

Add a title Label. Text: "My Leave Requests".

4

Add a New Request button. Text: "+ New Request". OnSelect: Navigate(NewRequestScreen, ScreenTransition.Fade).

5

Add a Gallery control (Vertical gallery). Set the Items property to the filter formula below.

6

Inside the gallery, add Labels for: Title (Request Reference), LeaveType, StartDate, EndDate, WorkingDays, Status.

7

Add a status badge Label inside the gallery. Set the Fill property to a colour based on the status (see formula below).

8

Set the gallery OnSelect property: Set(SelectedRequest, ThisItem); Navigate(RequestDetailScreen, ScreenTransition.Fade). This stores the selected record and navigates to the detail screen.

9

Add an empty state Label. Text: "You have no leave requests yet." Visible formula: CountRows(Gallery1.AllItems) = 0.

10

Set the screen OnVisible property: Refresh(LeaveRequests). This refreshes the data every time the screen is shown, ensuring the gallery shows the latest status.

MyRequestsGallery — Items propertyPower Fx
Filter( LeaveRequests, EmployeeEmail = User().Email )

What this does: Filter returns only the rows from LeaveRequests where the EmployeeEmail column equals the logged-in user's email address. This ensures employees only see their own requests (SEC-001). The filter runs on the SharePoint server (it is delegable), so it works correctly even with large lists.

StatusBadge — Fill property (colour-coded status)Power Fx
Switch( ThisItem.Status, "Approved", RGBA(34, 197, 94, 0.15), "Rejected", RGBA(239, 68, 68, 0.15), "Submitted", RGBA(59, 130, 246, 0.15), "Cancelled", RGBA(245, 158, 11, 0.15), RGBA(156, 163, 175, 0.15) )

What this does: Switch evaluates ThisItem.Status and returns a different background colour for each value. The last argument (RGBA(156, 163, 175, 0.15)) is the default — used for Draft status. RGBA values are Red, Green, Blue, Alpha (transparency).

Step 5 — Build Screen 3: New Request

Why Explain Formula Logic?

The New Request screen has the most complex logic in the app. Rather than just listing the formulas, this section explains what each formula is doing and why. Understanding the logic means you can adapt it when requirements change — for example, adding a new validation rule.
1

Add a new screen. Rename it "NewRequestScreen".

2

Add a Back button. Text: "← Back". OnSelect: Navigate(HomeScreen, ScreenTransition.Back).

3

Add a title Label. Text: "New Leave Request".

4

Add a Dropdown control for Leave Type. Items: ["Annual Leave", "Sick Leave", "Other"]. Label above it: "Leave Type *".

5

Add a DatePicker control for Start Date. Label above it: "Start Date *".

6

Add a DatePicker control for End Date. Label above it: "End Date *".

7

Add a Label for Working Days. Text formula: see below. Label above it: "Working Days (weekdays only)".

8

Add a Text Input for Manager Name. Label above it: "Manager Name *". Hint text: "e.g. Priya Sharma".

9

Add a Text Input for Manager Email. Label above it: "Manager Email *". Hint text: "e.g. priya.sharma@contoso.co.uk".

10

Add a Text Input (multiline) for Comments. Label above it: "Comments (optional)".

11

Add validation error Labels (see validation section below).

12

Add a "Save as Draft" button and a "Submit" button (see submit logic below).

WorkingDaysLabel — Text propertyPower Fx
Text( RoundDown( (DateDiff(StartDatePicker.SelectedDate, EndDatePicker.SelectedDate, Days) + 1) - (2 * RoundDown( (Weekday(StartDatePicker.SelectedDate, StartOfWeek.Monday) + DateDiff(StartDatePicker.SelectedDate, EndDatePicker.SelectedDate, Days)) / 7, 1 )), 0 ), "0" ) & " working day(s)"

What this does: This formula calculates the number of weekdays between two dates. It starts with the total days (including the end date), then subtracts the number of weekend days. The Weekday() function returns the day of the week (1=Monday, 7=Sunday with StartOfWeek.Monday). The RoundDown(x/7) * 2 pattern counts the number of complete weeks (each containing 2 weekend days). This is a simplified calculation — it does not account for bank holidays.

Step 6 — Validation Logic

Validation prevents invalid data from being submitted. Each validation rule has a corresponding error label that is shown when the rule fails and hidden when it passes.

Validation: Start date is blank

Error text: "Please select a start date."

Visible property formula

IsBlank(StartDatePicker.SelectedDate)

IsBlank() returns true if the date picker has no value selected. The label is visible when this is true.

Validation: End date is blank

Error text: "Please select an end date."

Visible property formula

IsBlank(EndDatePicker.SelectedDate)

Same pattern as start date.

Validation: End date is before start date

Error text: "End date cannot be before start date."

Visible property formula

EndDatePicker.SelectedDate < StartDatePicker.SelectedDate

Compares the two date values directly. In Power Fx, date values can be compared with < and >. This is true (error shown) when the end date is earlier than the start date.

Validation: Leave type not selected

Error text: "Please select a leave type."

Visible property formula

IsBlank(LeaveTypeDropdown.Selected.Value)

Checks whether the dropdown has a selected value. IsBlank() on a dropdown's Selected.Value returns true if nothing is selected.

Validation: Manager email is blank

Error text: "Please enter your manager's email address."

Visible property formula

IsBlank(ManagerEmailInput.Text)

Checks whether the manager email text input is empty.

Validation: Manager email does not look like an email

Error text: "Please enter a valid email address."

Visible property formula

!IsBlank(ManagerEmailInput.Text) && !("@" in ManagerEmailInput.Text)

The ! operator means NOT. This rule is only shown when the field is not blank (to avoid showing two errors at once) AND the text does not contain "@". This is a basic check — it does not verify the email address exists.

Common Mistake

Client-side validation (validation in the app) does not constitute complete security. A determined user could bypass the app entirely and write directly to the SharePoint list using the SharePoint API or the Microsoft Lists interface. True data integrity requires server-side validation — for example, a Power Automate flow that checks data quality when a record is created. For this lab, client-side validation is sufficient, but you should be aware of this limitation.

Step 7 — Submit and Save as Draft Logic

SubmitButton — DisplayMode propertyPower Fx
If( IsBlank(StartDatePicker.SelectedDate) || IsBlank(EndDatePicker.SelectedDate) || EndDatePicker.SelectedDate < StartDatePicker.SelectedDate || IsBlank(LeaveTypeDropdown.Selected.Value) || IsBlank(ManagerNameInput.Text) || IsBlank(ManagerEmailInput.Text), DisplayMode.Disabled, DisplayMode.Edit )

What this does: This formula disables the Submit button when any required field is blank or any validation rule fails. The || operator means OR — if any one condition is true, the button is disabled. DisplayMode.Disabled makes the button grey and unclickable. DisplayMode.Edit makes it active.

SubmitButton — OnSelect propertyPower Fx
Patch( LeaveRequests, Defaults(LeaveRequests), { Title: "LR-" & Text(Now(), "YYYYMMDD") & "-" & Text(Rand() * 9999, "0000"), EmployeeName: User().FullName, EmployeeEmail: User().Email, ManagerName: ManagerNameInput.Text, ManagerEmail: ManagerEmailInput.Text, LeaveType: LeaveTypeDropdown.Selected.Value, StartDate: StartDatePicker.SelectedDate, EndDate: EndDatePicker.SelectedDate, WorkingDays: Value(WorkingDaysLabel.Text), EmployeeComments: CommentsInput.Text, Status: "Submitted", SubmittedDate: Now() } ); Notify("Your leave request has been submitted.", NotificationType.Success); Navigate(MyRequestsScreen, ScreenTransition.Fade)

What this does: Patch() creates a new record in the LeaveRequests list. Defaults(LeaveRequests) provides the default values for all fields not specified. The record is created with Status = Submitted, which will trigger the Power Automate flow. After creating the record, Notify() shows a success message and Navigate() returns the user to the My Requests screen.

SaveDraftButton — OnSelect propertyPower Fx
Patch( LeaveRequests, Defaults(LeaveRequests), { Title: "LR-DRAFT-" & Text(Now(), "YYYYMMDD"), EmployeeName: User().FullName, EmployeeEmail: User().Email, ManagerName: ManagerNameInput.Text, ManagerEmail: ManagerEmailInput.Text, LeaveType: If(IsBlank(LeaveTypeDropdown.Selected.Value), "", LeaveTypeDropdown.Selected.Value), StartDate: StartDatePicker.SelectedDate, EndDate: EndDatePicker.SelectedDate, WorkingDays: 0, EmployeeComments: CommentsInput.Text, Status: "Draft" } ); Notify("Draft saved.", NotificationType.Information); Navigate(MyRequestsScreen, ScreenTransition.Fade)

What this does: The Save as Draft button uses the same Patch() pattern but sets Status = Draft. This does NOT trigger the Power Automate flow (the flow only fires on new records, and the flow's condition checks for Status = Submitted). Required field validation is not enforced for drafts — the employee can save an incomplete request.

Step 8 — Build Screen 4: Request Details

1

Add a new screen. Rename it "RequestDetailScreen".

2

Add a Back button. OnSelect: Navigate(MyRequestsScreen, ScreenTransition.Back).

3

Add a title Label. Text: SelectedRequest.Title (this displays the request reference of the record selected in the gallery).

4

Add a status badge Label. Text: SelectedRequest.Status. Fill: use the same Switch() formula as the gallery status badge.

5

Add read-only Labels for each field: Leave Type, Start Date, End Date, Working Days, Employee Comments, Submitted Date. Each label's Text property references the corresponding field of SelectedRequest (e.g. Text(SelectedRequest.StartDate, "DD/MM/YYYY")).

6

Add a Decision section container. Visible formula: SelectedRequest.Status in ["Approved", "Rejected"]. Inside: Labels for Decision Date, Approver, Approver Comments.

7

Add a Cancel Request button. Text: "Cancel Request". Visible formula: SelectedRequest.Status = "Submitted". OnSelect: see formula below.

CancelRequestButton — OnSelect propertyPower Fx
If( Confirm("Are you sure you want to cancel this request?"), Patch( LeaveRequests, SelectedRequest, { Status: "Cancelled" } ); Notify("Request cancelled.", NotificationType.Warning); Navigate(MyRequestsScreen, ScreenTransition.Fade) )

What this does: Confirm() shows a confirmation dialog. If the user selects OK (true), Patch() updates the existing record (SelectedRequest) by changing only the Status field to Cancelled. This is different from the submit Patch() — here we pass SelectedRequest as the second argument (the record to update) rather than Defaults() (which creates a new record).

Step 9 — Build Screen 5: Administration

1

Add a new screen. Rename it "AdminScreen".

2

Add a Back button. OnSelect: Navigate(HomeScreen, ScreenTransition.Back).

3

Add a title Label. Text: "Administration — All Requests".

4

Add a Dropdown for status filter. Items: ["All", "Draft", "Submitted", "Approved", "Rejected", "Cancelled"]. Label: "Filter by Status".

5

Add a Text Input for employee name search. Label: "Search by Employee Name". Hint text: "Type a name to filter".

6

Add a Gallery. Items formula: see below.

7

Inside the gallery, add Labels for: Title, EmployeeName, LeaveType, StartDate, EndDate, Status.

8

Add a record count Label. Text formula: CountRows(AdminGallery.AllItems) & " record(s)".

9

Set the screen OnVisible property: Refresh(LeaveRequests).

AdminGallery — Items propertyPower Fx
Filter( LeaveRequests, (StatusFilterDropdown.Selected.Value = "All" || Status = StatusFilterDropdown.Selected.Value) && (IsBlank(EmployeeSearchInput.Text) || StartsWith(EmployeeName, EmployeeSearchInput.Text)) )

What this does: This filter combines two conditions with &&. The first condition checks the status filter: if 'All' is selected, all records pass; otherwise only records matching the selected status pass. The second condition checks the search input: if the search box is empty, all records pass; otherwise only records where EmployeeName starts with the search text pass. StartsWith() is delegable to SharePoint, so this works correctly with large lists.

Try It Yourself — Build the App

Build all five screens following the steps above. When complete, test the following scenarios manually:

  1. 1.Open the app. Verify your name appears in the welcome label on the Home screen.
  2. 2.Navigate to My Requests. Verify only your own records appear (if you entered sample data with your email address).
  3. 3.Navigate to New Request. Try to submit without filling in any fields. Verify the Submit button is disabled.
  4. 4.Fill in all fields with valid data. Verify the Submit button becomes active. Verify the working days label updates when you change the dates.
  5. 5.Submit a request. Verify you see the success notification and are returned to My Requests. Verify the new record appears in the gallery.
  6. 6.Open the new record in Request Details. Verify all fields are displayed correctly. Verify the Cancel button is visible (Status = Submitted).

Stage Complete — What You Now Have

  • ✓A Power Apps canvas app with five screens connected to the Leave Requests list
  • ✓A personalised Home screen showing the logged-in user's name and pending request count
  • ✓A My Requests screen filtered to show only the current user's requests
  • ✓A New Request screen with six validation rules and a working days calculator
  • ✓Submit logic using Patch() that creates a Submitted record and triggers the flow
  • ✓A Request Details screen with a Cancel button that updates the status to Cancelled
  • ✓An Administration screen with status filter and employee name search

Need more help with the concepts?

Visit DosToDigital for guides, templates, and deeper explanations.

DosToDigital
DToD Labs

Learn it. Build it. Make it work.

A DosToDigital Project

About DToD Labs

Practical technology learning for Microsoft 365 and Power Platform. Build real business solutions from real business problems.

Learn the concepts at DosToDigital. Put them into practice at DToD Labs.

DToD Labs provides practical learning projects for educational purposes. Microsoft services, interfaces, licensing and product capabilities change over time. Always check current Microsoft documentation and licensing before implementing a solution in a production environment. All organisations, business scenarios and data used in DToD Labs are fictional. Learners should not use confidential employer, customer or personal information when following DToD Labs exercises.

© 2026 DToD Labs — A DosToDigital Project