Stage 9 of 17

Stage 9 of 17

Automate — DToDLab002-LeaveApproval

In this stage you will build the Power Automate approval flow. The flow is triggered when a new leave request is submitted, sends an approval email to the manager, updates the list record with the decision, and notifies the employee. Every action is documented with its configuration and the reasoning behind it.

Why Are We Doing This?

The Power Automate flow is the engine of the approval process. Without it, the app is just a data entry form — requests would be submitted but nothing would happen. The flow connects the employee's submission to the manager's decision and back to the employee's notification. Understanding how the flow works is essential for supporting it when something goes wrong.

Step 1 — Create the Flow

1

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

2

Select "+ Create" from the left navigation. Choose "Automated cloud flow".

3

Flow name: "DToDLab002-LeaveApproval". Search for the trigger: "When an item is created". Select the SharePoint trigger "When an item is created". Select Create.

4

Configure the trigger: Site Address: select your Leave Request System SharePoint site. List Name: select "Leave Requests". Select Save.

Common Mistake

The trigger fires for every new item created in the list — including Draft records. If you do not add the status check condition (Action 2), the flow will send an approval email every time an employee saves a draft. This is why the condition is essential.

Action 1 — Trigger: When an item is created

T

Trigger: When an item is created

SharePoint connector

Site Address

https://[tenant].sharepoint.com/sites/LeaveRequestSystem

List Name

Leave Requests

Important: This trigger fires for every new item, including Drafts. The next action (the status condition) prevents the flow from proceeding for non-Submitted records.

Action 2 — Condition: Is the status Submitted?

2

Condition: Check if Status = Submitted

Select "+ New step" → "Condition". Configure the condition:

Statusis equal to"Submitted"

To add the Status field: in the left box, select "Add dynamic content". Find "Status" in the list of fields from the trigger. Select it. In the middle box, select "is equal to". In the right box, type "Submitted" (exactly as it appears in the choice column).

If Yes

Continue to the approval action (Actions 3–8).

If No

Add a Terminate action with Status = Succeeded. This ends the flow gracefully for Draft records.

Action 3 — Start and Wait for an Approval

3

Start and wait for an approval

Inside the Yes branch of the condition, select "+ Add an action". Search for "Approvals". Select "Start and wait for an approval". Configure as follows:

Approval type

Approve/Reject — First to respond

Title

"Leave Request — " + EmployeeName + " — " + StartDate + " to " + EndDate (use dynamic content)

Assigned to

ManagerEmail (dynamic content from trigger)

Details

Build a message including: Employee Name, Leave Type, Start Date, End Date, Working Days, Employee Comments. Use dynamic content for each field.

Item link

Optional: the URL of the SharePoint list item. Allows the manager to open the full record.

Flow pause: The flow pauses at this action until the manager responds. The flow run will show as "Running" in the run history until a response is received. If the manager never responds, the flow will eventually time out (after 30 days for standard flows).

Approval Title — dynamic content expressionExpression
concat( 'Leave Request — ', triggerOutputs()?['body/EmployeeName'], ' — ', formatDateTime(triggerOutputs()?['body/StartDate'], 'dd/MM/yyyy'), ' to ', formatDateTime(triggerOutputs()?['body/EndDate'], 'dd/MM/yyyy') )

What this does: concat() joins multiple strings together. triggerOutputs()?['body/EmployeeName'] retrieves the EmployeeName field from the trigger output. The ?[] syntax is safe navigation — it returns null rather than an error if the field is missing. formatDateTime() formats the date in a readable format. You can build this using the dynamic content picker rather than typing the expression manually.

Action 4 — Condition: Was the request approved?

4

Condition: Check approval outcome

After the approval action, add another Condition. Configure:

Outcomeis equal to"Approve"

The Outcome field comes from the approval action's dynamic content. It will be either "Approve" or "Reject" depending on which button the manager selected in the approval email.

If Yes (Approved)

Update list record with Status = Approved. Send approval notification email.

If No (Rejected)

Update list record with Status = Rejected. Send rejection notification email.

Actions 5 & 6 — Approved Branch

5

Update item — Set Status to Approved

Inside the Yes branch, add "SharePoint — Update item". Configure:

Site Address

Your Leave Request System site

List Name

Leave Requests

ID

ID (dynamic content from trigger — the ID of the record that triggered the flow)

Status

"Approved"

Approver

Responders Approver name (dynamic content from the approval action)

Decision Date

utcNow() expression — the current date and time

Approver Comments

Responders Comments (dynamic content from the approval action)

6

Send email — Approval notification to employee

Add "Office 365 Outlook — Send an email (V2)". Configure:

To

EmployeeEmail (dynamic content from trigger)

Subject

"Your leave request has been approved — " + StartDate + " to " + EndDate

Body

Include: employee name, leave type, dates, working days, approver name, approver comments, and a note to contact HR if they have questions.

Actions 7 & 8 — Rejected Branch

7

Update item — Set Status to Rejected

Inside the No branch, add "SharePoint — Update item". Configure identically to Action 5, except set Status to "Rejected". The Approver, Decision Date, and Approver Comments fields are populated the same way — from the approval action's dynamic content.

8

Send email — Rejection notification to employee

Add "Office 365 Outlook — Send an email (V2)". Configure:

To

EmployeeEmail (dynamic content from trigger)

Subject

"Your leave request has been rejected — " + StartDate + " to " + EndDate

Body

Include: employee name, leave type, dates, approver name, and approver comments. The approver comments are especially important for rejections (DF-004) — the employee needs to know why.

Action 9 — Terminate (No branch of Action 2)

9

Terminate — Graceful exit for non-Submitted records

In the No branch of Action 2 (the status condition), add "Control — Terminate". Set Status to "Succeeded". Do not use "Failed" — a Failed status generates alerts and makes the run history look like something went wrong, when in fact the flow correctly identified a non-Submitted record and stopped.

Testing the Flow

1

Save the flow. Select "Test" → "Manually" → "Test".

2

Open the Power Apps app. Submit a new leave request with your own email as the employee email and a test manager email (ideally an email address you can access).

3

Return to Power Automate. The flow should show as "Running" in the run history.

4

Check the manager's email inbox. An approval email should arrive with Approve and Reject buttons.

5

Select Approve. Add a comment: "Approved — enjoy your holiday."

6

Return to Power Automate. The flow should now show as "Succeeded".

7

Check the employee's email inbox. An approval notification should have arrived.

8

Open the Leave Requests list in Microsoft Lists. Find the record. Verify: Status = Approved, Approver = your name, Decision Date = today, Approver Comments = "Approved — enjoy your holiday."

9

Open the Power Apps app. Navigate to My Requests. Verify the request shows Status = Approved.

Add the IT Manager as Co-Owner

SUP-003 requires the IT Manager to be added as a co-owner of the flow. This prevents the flow from failing if the original creator's account is disabled or the person leaves the organisation.

1

Open the flow in Power Automate.

2

Select the three-dot menu (or look for "Share" or "Manage" in the flow details). Find the option to add co-owners or share the flow.

3

Add the IT Manager's email address (Marcus Webb / marcus.webb@contoso.co.uk in the fictional scenario, or your IT Manager's real email in a real deployment).

4

The co-owner can now view, edit, and manage the flow.

Error Considerations

Manager email is invalid

What happens

The approval action will fail with an error. The flow run will show as Failed.

How to handle it: Check the run history. Expand the failed action to see the error message. Correct the manager email in the list record and re-trigger the flow manually (or ask the employee to submit a new request).

Manager never responds

What happens

The flow will wait indefinitely (up to 30 days for standard flows). After 30 days, the flow times out and the request remains in Submitted status.

How to handle it: The reminder flow (FR-016) helps by sending a reminder after two working days. For a timed-out request, the IT Manager can manually update the status in the list.

Flow fails after the approval but before the list update

What happens

The manager has approved but the list record still shows Submitted. The employee has not been notified.

How to handle it: Check the run history. Find the failed action. Correct the issue and re-run the flow from the failed action (Power Automate supports re-running from a specific action in some cases). Alternatively, manually update the list record.

Employee cancels the request while the flow is waiting for approval

What happens

The flow is still waiting for the manager's response. When the manager responds, the flow will update the status to Approved or Rejected, overwriting the Cancelled status.

How to handle it: This is a known limitation of the v1 design. A more robust solution would check the current status before updating it. Add a condition before the Update item actions: if Status = Cancelled, terminate instead of updating.

Stage Complete — What You Now Have

  • ✓A nine-action Power Automate flow: DToDLab002-LeaveApproval
  • ✓Trigger: fires on new list items; condition filters to Submitted only
  • ✓Approval action: sends structured email to manager with Approve/Reject buttons
  • ✓Approved branch: updates list record and sends approval notification to employee
  • ✓Rejected branch: updates list record and sends rejection notification with manager comments
  • ✓IT Manager added as flow co-owner (SUP-003)
  • ✓Four error scenarios documented with handling guidance
NextSecure

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