Skip to content
Tutorials Center
My learning

Topics

Lesson 35 of 38 ยท Projects and Practice

Project: Expense Approval App

Plan and build an expense approval solution: Dataverse tables, a canvas submit app, an approval flow, security roles and ALM. Includes runnable logic stand-ins.

This project ties together much of the course: a canvas app for employees to submit expenses, a Power Automate approval flow, Dataverse tables, security roles and a solution you can deploy. The platform cannot run here, so each part is described step by step, and the business rules are written as runnable stand-ins you can test.

The requirements

  • Employees submit an expense with a title, amount, category, date and an optional receipt.
  • Amounts up to 100 are approved automatically; amounts from 100 up to 1,000 need the manager; above 1,000 they also need finance.
  • Employees see only their own expenses; managers see their team's; finance sees all.
  • Every decision is stored with who decided and when.

Step 1: the data model

In a new solution (publisher prefix ex), create these Dataverse tables:

  • Expense (ex_expense): Title (text), Amount (currency), Category (choice: Travel, Meals, Equipment, Other), Expense Date (date only), Status (choice: Draft, Submitted, Approved, Rejected), Submitted By (lookup to User, or the built-in Owner), Receipt (file column), Manager Comment (multiline text).
  • Expense Approval (ex_expenseapproval): Expense (lookup), Approver (lookup to User), Level (choice: Manager, Finance), Decision (choice), Decided On (date and time).

Relationship: one Expense has many Approvals (1:N). Use user or team owned tables for Expense so security by owner works (Security Roles, Sharing and Row Access).

Project parts

Dataverse Expense and Approval tables
Canvas app Submit and track
Flow Approval routing
Roles Employee, Manager, Finance
1 / 2

Step 2: the routing rule as logic

The approval routing is a pure function of the amount, which is perfect to design and test before building the flow. The stand-in below is what the flow's Condition actions will implement.

JS Stand-in: approval routing rule

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check the boundaries: 100 and 1000 belong to the lower band, 1000.01 to the higher. Write the boundaries into your test plan.

Step 3: the canvas app

Create a canvas app from Dataverse (phone layout) or from blank. Three screens:

  1. My expenses: a gallery over Filter(Expenses, Owner.'Primary Email' = User().Email) sorted by date descending, with a status badge. A button New navigates to the form.
  2. New expense: an Edit form (frmExpense) bound to Expenses, with Item empty (new mode). The Submit button runs:
TEXT
If(
    frmExpense.Valid,
    SubmitForm(frmExpense),
    Notify("Please fix the highlighted fields.", NotificationType.Error)
)

and the form's OnSuccess sets the status and calls the flow:

TEXT
Patch(Expenses, frmExpense.LastSubmit, { Status: 'Status (Expenses)'.Submitted });
SubmitExpenseApproval.Run(frmExpense.LastSubmit.Expense);
Navigate(scrMine, ScreenTransition.None)
  1. Details: a display form with the approvals gallery (Filter(Approvals, Expense.Expense = galExpenses.Selected.Expense)) showing level, decision and date.

Validation rules to put in the fields: amount greater than 0, date not in the future, receipt required above 25. The stand-in below lets you test them before you write the formulas.

JS Stand-in: form validation rules

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Step 4: the approval flow

Create a flow in the solution named SubmitExpenseApproval:

  1. Trigger Power Apps (V2) with one input: Expense ID (text).
  2. Get a row by ID from Expenses.
  3. Condition on Amount: under 100 sets Status to Approved and finishes.
  4. Otherwise Start and wait for an approval (Approvals connector) assigned to the submitter's manager (use the Office 365 Users connector, Get manager (V2)).
  5. When the manager decides, Add a new row to Expense Approval with the decision.
  6. If rejected: set Status to Rejected and send an email with the comment. If approved and amount over 1000, repeat step 4 for the finance group.
  7. Finally set Status to Approved and notify the employee.

Use a connection reference and an environment variable for the finance group's address (Environment Variables and Connection References).

Step 5: security roles

Create three roles copied from Basic User and adjusted:

  • Expense Employee: Expense Create/Read/Write at User level; Approval Read at User.
  • Expense Manager: Expense Read at Business unit (or use hierarchy security); Approval Create/Read/Write at Business unit.
  • Expense Finance: Read at Organization on both tables, and the ability to Write Expense status.

Assign roles to Entra ID group teams, not individuals.

Step 6: test and ship

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. An expense of exactly 1000 needs which approvals in our design?

    The manager band is 100 to 1,000 inclusive; finance is added only above 1,000.
  2. 2. Which security level gives an employee only their own expenses?

    User level limits access to rows the user owns.
  3. 3. Where should the finance group's address live so Test and Prod differ?

    Environment variables hold per-environment values outside the solution logic.
  4. 4. Why return a status and not just run the flow?

    Returning a status lets the app respond to success and failure.

Summary

  • Model the data first, then the logic (routing rule), then screens, flow and security.
  • Test boundaries and validation as plain functions before building them in Power Apps.
  • Use roles for access, environment variables and connection references for portability, and ship as a managed solution.

Next: Project: Inventory Model-driven App