Stage 8 of 17

Stage 8 of 17

Build

Build all 9 screens of the DToDLab012-SupplierContracts Canvas Power App. Detailed build steps, formulas, and test for every screen.

App OnStart — Global Variables

Before building individual screens, set up the App OnStart formula. This runs once when the app loads and sets up global variables used across all screens.

App OnStart

// Set current user Set(varCurrentUser, Office365Users.MyProfileV2()); // Determine if current user is in the Procurement Team // Replace with actual procurement team email addresses ClearCollect( colProcurementEmails, {Email: "j.okafor@contoso.co.uk"}, {Email: "p.mehta@contoso.co.uk"}, {Email: "h.marsh@contoso.co.uk"}, {Email: "t.reeves@contoso.co.uk"} ); Set(varIsProcurement, !IsBlank(LookUp(colProcurementEmails, Email = varCurrentUser.mail))); // Load all lists into collections for performance ClearCollect(colSuppliers, Suppliers); ClearCollect(colContracts, Contracts); ClearCollect(colRisks, Risks); ClearCollect(colActions, Actions); // Navigate to Dashboard Navigate(scrDashboard);

Collections vs Direct Queries

Loading all records into collections (ClearCollect) on startup means the app queries SharePoint once rather than on every screen navigation. This is faster for small datasets (under 500 records). For larger datasets, use direct Filter() queries against the SharePoint lists instead.

Screen Builds

1

Dashboard (scrDashboard)

First screen. KPI cards and galleries for expiring contracts, critical risks, and overdue actions.

Build Steps

  1. 1.Add 4 KPI cards at the top of the screen. Each card has a large number label and a description label.
  2. 2.KPI 1 — Contracts expiring in 30 days: set the number label Text to the CountIf formula below.
  3. 3.KPI 2 — Open critical risks: set the number label Text to the CountIf formula below.
  4. 4.KPI 3 — Overdue actions: set the number label Text to the CountIf formula below.
  5. 5.KPI 4 — Contracts under review: set the number label Text to the CountIf formula below.
  6. 6.Add a Gallery below the KPI cards for expiring contracts. Set Items to the Filter formula below. Add columns: ContractID, Title, Supplier.Title, EndDate, DaysToExpiry.
  7. 7.Add a Gallery for open critical risks. Set Items to the Filter formula below.
  8. 8.Add a Gallery for overdue actions. Set Items to the Filter formula below.
  9. 9.Add a navigation bar at the bottom with buttons: Suppliers, Contracts, Reviews, Risks, Actions. Each button navigates to the corresponding screen.

Formulas

KPI 1 — Contracts expiring in 30 days

CountIf(colContracts, DateDiff(Today(), EndDate, Days) <= 30, Status <> "Terminated", Status <> "Expired", Status <> "Cancelled")

KPI 2 — Open critical risks

CountIf(colRisks, RiskRating = "Critical", Status <> "Closed")

KPI 3 — Overdue actions

CountIf(colActions, DueDate < Today(), Status <> "Complete")

KPI 4 — Contracts under review

CountIf(colContracts, Status = "Under Review")

Expiring contracts gallery Items

Sort(Filter(colContracts, DateDiff(Today(), EndDate, Days) <= 30, Status <> "Terminated"), EndDate, Ascending)

Critical risks gallery Items

Filter(colRisks, RiskRating = "Critical", Status <> "Closed")

Overdue actions gallery Items

Filter(colActions, DueDate < Today(), Status <> "Complete")

Test

Verify all 4 KPI cards show non-zero values (using the sample data from Stage 5). Verify CON-012 appears in the expiring contracts gallery. Verify RSK-001 appears in the critical risks gallery.

2

Suppliers (scrSuppliers)

Filterable list of all suppliers.

Build Steps

  1. 1.Add a text input (txtSupplierSearch) for searching by name.
  2. 2.Add a dropdown (ddSupplierCategory) with options: All, IT, Facilities, Professional Services, Logistics, Other.
  3. 3.Add a dropdown (ddSupplierStatus) with options: All, Active, Inactive, Under Review.
  4. 4.Add a Gallery with Items set to the Filter formula below.
  5. 5.Each gallery row: SupplierID, Title (supplier name), Category, Status badge.
  6. 6.Add a New Supplier button. Visible: varIsProcurement. OnSelect: Set(varEditMode, false); Navigate(scrNewSupplier).
  7. 7.Each gallery row OnSelect: Set(varSelectedSupplier, ThisItem); Navigate(scrSupplierDetails).

Formulas

Gallery Items

Filter( colSuppliers, (txtSupplierSearch.Text = "" || Title in txtSupplierSearch.Text), (ddSupplierCategory.Selected.Value = "All" || Category = ddSupplierCategory.Selected.Value), (ddSupplierStatus.Selected.Value = "All" || Status = ddSupplierStatus.Selected.Value) )

Test

Search for 'Cloud'. Verify CloudCore Ltd and DataVault Security appear. Filter by Category = IT. Verify only IT suppliers appear.

3

Supplier Details (scrSupplierDetails)

Full details for a selected supplier.

Build Steps

  1. 1.Display supplier header: Title, Category badge, Status badge.
  2. 2.Display contact details: PrimaryContactName, PrimaryContactEmail, PrimaryContactPhone, AccountManagerName, AccountManagerEmail.
  3. 3.Add a Gallery for linked contracts: Items = Filter(colContracts, Supplier.Id = varSelectedSupplier.ID, Status <> "Terminated").
  4. 4.Add a Gallery for open risks: Items = Filter(colRisks, Supplier.Id = varSelectedSupplier.ID, Status <> "Closed").
  5. 5.Add an Edit button. Visible: varIsProcurement. OnSelect: Set(varEditMode, true); Navigate(scrNewSupplier).
  6. 6.Add a Back button. OnSelect: Back().

Formulas

Linked contracts

Filter(colContracts, Supplier.Id = varSelectedSupplier.ID, Status <> "Terminated")

Open risks

Filter(colRisks, Supplier.Id = varSelectedSupplier.ID, Status <> "Closed")

Test

Select CloudCore Ltd from the Suppliers screen. Verify CON-001, CON-002, CON-012 appear in linked contracts. Verify RSK-001 and RSK-003 appear in open risks.

4

Contracts (scrContracts)

Filterable list of all contracts with expiry highlighting.

Build Steps

  1. 1.Add a text input (txtContractSearch) for searching by title.
  2. 2.Add dropdowns for Status, Category, and Criticality filters.
  3. 3.Add a Gallery with Items set to the Filter formula below.
  4. 4.Each gallery row: ContractID, Title, Supplier.Title, Status badge, AnnualValue (formatted as currency), EndDate, DaysToExpiry with colour coding.
  5. 5.DaysToExpiry colour: If(DaysToExpiry <= 30, Red, If(DaysToExpiry <= 90, Amber, Green)).
  6. 6.Add a New Contract button. Visible: varIsProcurement.
  7. 7.Each gallery row OnSelect: Set(varSelectedContract, ThisItem); Navigate(scrContractDetails).

Formulas

DaysToExpiry (add as a calculated label in the gallery)

Text(DateDiff(Today(), ThisItem.EndDate, Days)) & " days"

DaysToExpiry colour

If(DateDiff(Today(), ThisItem.EndDate, Days) <= 30, RGBA(220,38,38,1), If(DateDiff(Today(), ThisItem.EndDate, Days) <= 90, RGBA(245,158,11,1), RGBA(34,197,94,1)))

AnnualValue formatted

Text(ThisItem.AnnualValue, "£#,##0")

Test

Verify CON-012 (Terminating, end date 31 Dec 2026) shows a red DaysToExpiry. Verify the total annual value of all contracts is visible when you add up the gallery rows.

5

Contract Details (scrContractDetails)

Full contract details with tabbed sections for Services, Reviews, Risks, and Actions.

Build Steps

  1. 1.Display contract header: Title, Supplier.Title, Status badge, Criticality badge.
  2. 2.Display key dates: StartDate, EndDate, NoticePeriodDeadline (calculated), ReviewDate, DaysToExpiry.
  3. 3.Display financial: AnnualValue (formatted), Currency.
  4. 4.Add 4 tab buttons: Services, Reviews, Risks, Actions. Each button sets varContractTab to the tab name.
  5. 5.Add 4 galleries, each Visible based on varContractTab.
  6. 6.Services gallery: Filter(Services, Contract.Id = varSelectedContract.ID).
  7. 7.Reviews gallery: Filter(Reviews, Contract.Id = varSelectedContract.ID), sorted by ReviewDate descending.
  8. 8.Risks gallery: Filter(colRisks, Contract.Id = varSelectedContract.ID, Status <> "Closed").
  9. 9.Actions gallery: Filter(colActions, LinkedContract.Id = varSelectedContract.ID, Status <> "Complete").
  10. 10.Add action buttons: Add Review, Add Risk, Add Action. Visible: varIsProcurement.

Formulas

NoticePeriodDeadline

Text(DateAdd(varSelectedContract.EndDate, -varSelectedContract.NoticePeriodDays, Days), "dd mmm yyyy")

Tab visibility (Services gallery)

varContractTab = "Services"

Add Review button OnSelect

Set(varNewReviewContract, varSelectedContract); Navigate(scrNewReview)

Test

Select CON-001. Verify the NoticePeriodDeadline is calculated correctly (EndDate minus NoticePeriodDays). Switch between tabs. Verify each tab shows the correct records.

6

Reviews (scrReviews)

List of all reviews and new review form.

Build Steps

  1. 1.Add a Gallery showing all reviews, sorted by ReviewDate descending.
  2. 2.Each row: ReviewDate, Contract.Title, Supplier.Title, Outcome badge.
  3. 3.Add a New Review button. Visible: varIsProcurement. OnSelect: Navigate(scrNewReview).
  4. 4.Build scrNewReview: Contract dropdown (lookup), ReviewDate (date picker), Attendees (text area), Outcome (dropdown: Renew/Renegotiate/Replace/Terminate/No Decision), Notes (text area), NextReviewDate (date picker).
  5. 5.Save button OnSelect: Patch(Reviews, Defaults(Reviews), {Contract: {Id: ddReviewContract.Selected.ID, Value: ddReviewContract.Selected.Title}, Supplier: {Id: varReviewSupplier.ID, Value: varReviewSupplier.Title}, ReviewDate: dpReviewDate.SelectedDate, ...}); Back().

Formulas

Auto-populate Supplier from Contract selection

Set(varReviewSupplier, LookUp(colSuppliers, ID = LookUp(colContracts, ID = ddReviewContract.Selected.ID).Supplier.Id))

Outcome badge colour

Switch(ThisItem.Outcome, "Terminate", RGBA(220,38,38,1), "Replace", RGBA(234,88,12,1), "Renegotiate", RGBA(245,158,11,1), "Renew", RGBA(34,197,94,1), RGBA(107,114,128,1))

Test

Create a new review for CON-004 (Meridian Manchester). Select Outcome = Renegotiate. Verify the review appears in the Reviews gallery and on the Contract Details screen for CON-004.

7

Risks (scrRisks)

List of all risks sorted by rating, with new risk form.

Build Steps

  1. 1.Add a Gallery showing all risks, sorted by RiskRating (Critical first) then Status.
  2. 2.Each row: Title, Supplier.Title, RiskRating badge (colour-coded), Status badge, Owner.DisplayName.
  3. 3.Add filter dropdowns for Status and RiskRating.
  4. 4.Add a New Risk button. Visible: varIsProcurement.
  5. 5.Build scrNewRisk: Title, Description, Supplier lookup, Contract lookup (optional), Likelihood dropdown, Impact dropdown, Owner person picker, Mitigation text area, TargetDate date picker.
  6. 6.RiskRating is not editable — it is calculated by the DToDLab012-RiskRatingCalc flow after saving.
  7. 7.Save button: Patch(Risks, Defaults(Risks), {...}); Back().

Formulas

Gallery sort (Critical first)

SortByColumns(Filter(colRisks, (ddRiskStatus.Selected.Value = "All" || Status = ddRiskStatus.Selected.Value)), "RiskRating", If(ddRiskRating.Selected.Value = "All", Ascending, Ascending))

RiskRating badge colour

Switch(ThisItem.RiskRating, "Critical", RGBA(220,38,38,1), "High", RGBA(234,88,12,1), "Medium", RGBA(245,158,11,1), RGBA(34,197,94,1))

Test

Verify RSK-001 (Critical) appears at the top of the list. Create a new risk with Likelihood = High, Impact = High. After the flow runs, verify RiskRating = Critical.

8

Actions (scrActions)

List of all actions with overdue highlighting.

Build Steps

  1. 1.Add a Gallery showing all actions, sorted by DueDate ascending.
  2. 2.Each row: Title, Owner.DisplayName, DueDate (red if overdue), Status badge.
  3. 3.Add filter dropdowns for Status and Owner.
  4. 4.Overdue indicator: DueDate label colour = If(ThisItem.DueDate < Today() && ThisItem.Status <> "Complete", RGBA(220,38,38,1), RGBA(107,114,128,1)).
  5. 5.Add a New Action button. Visible: varIsProcurement.
  6. 6.Each row OnSelect: Set(varSelectedAction, ThisItem); Navigate(scrActionDetails).
  7. 7.Build scrActionDetails: display all fields. Add Edit and Mark Complete buttons.
  8. 8.Mark Complete OnSelect: Patch(Actions, varSelectedAction, {Status: "Complete", CompletionDate: Today()}); ClearCollect(colActions, Actions); Back().

Formulas

Overdue DueDate colour

If(ThisItem.DueDate < Today() && ThisItem.Status <> "Complete", RGBA(220,38,38,1), RGBA(107,114,128,1))

Mark Complete

Patch(Actions, varSelectedAction, {Status: "Complete", CompletionDate: Today()}); ClearCollect(colActions, Actions); Back()

Test

Verify ACT-003 (due 31 Dec 2026) shows a red due date. Mark ACT-009 as Complete. Verify the status updates and the action disappears from the open actions gallery.

9

New / Edit Supplier and Contract forms

Forms for creating and editing supplier and contract records.

Build Steps

  1. 1.Build scrNewSupplier: all supplier fields from the data dictionary. Save and Cancel buttons.
  2. 2.Save button validation: Title is required. PrimaryContactEmail must contain "@".
  3. 3.Save OnSelect: Patch(Suppliers, If(varEditMode, varSelectedSupplier, Defaults(Suppliers)), {Title: txtTitle.Text, ...}); ClearCollect(colSuppliers, Suppliers); Back().
  4. 4.Build scrNewContract: all contract fields. Supplier lookup. Save and Cancel buttons.
  5. 5.Save OnSelect: Patch(Contracts, If(varEditMode, varSelectedContract, Defaults(Contracts)), {...}); ClearCollect(colContracts, Contracts); Back().

Formulas

Supplier save with validation

If( IsBlank(txtSupplierTitle.Text), Notify("Supplier name is required", NotificationType.Error), !("@" in txtPrimaryEmail.Text), Notify("Primary contact email must be a valid email address", NotificationType.Error), Patch(Suppliers, If(varEditMode, varSelectedSupplier, Defaults(Suppliers)), { Title: txtSupplierTitle.Text, Category: ddCategory.Selected.Value, Status: ddStatus.Selected.Value, PrimaryContactName: txtPrimaryName.Text, PrimaryContactEmail: txtPrimaryEmail.Text }); ClearCollect(colSuppliers, Suppliers); Back() )

Test

Create a new supplier. Leave the name blank and attempt to save. Verify the error message appears. Enter a valid name and save. Verify the supplier appears in the Suppliers gallery.

Stage Complete — What You Now Have

  • ✓9 screens built and connected
  • ✓App OnStart with global variables and procurement team check
  • ✓Dashboard with 4 KPI cards and 3 galleries
  • ✓Suppliers and Supplier Details with linked contracts and risks
  • ✓Contracts with expiry colour coding and NoticePeriodDeadline calculation
  • ✓Contract Details with tabbed Services / Reviews / Risks / Actions
  • ✓Reviews with auto-populated Supplier from Contract
  • ✓Risks with colour-coded rating badges
  • ✓Actions with overdue highlighting and Mark Complete
  • ✓New/Edit forms with validation

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