Building a Smarter Expense App: Direct Email Approvals without Flow


- Getting started with Microsoft Power Platform
- Understanding the Panes in Power Apps: A Beginner-Friendly Guide
- PowerApps: Global Variables, Context Variables and Collections
- Building an Expense App with PowerApps and SharePoint
- Gallery and DataTable
- Navigation, add, update & delete
- Custom Components & Component Libraries
- Building a Smarter Expense App: Direct Email Approvals without Flow (current)
- Protecting Admin Screens in Power Apps
- Publish your App
Building an Expense App using Power Apps
Approval Flow Using App & Data with Email Notifications (No Flow Required)
To send email notifications directly from PowerApps, add the Office 365 Outlook connector by following these steps:
-
Open PowerApps Studio and navigate to the Data tab.
-
Click on + Add data and search for Office365Outlook.
-
Select the connector and add it to your app.
The Office 365 Outlook connector provides functions such as Office365Outlook.SendEmail that are essential for sending notifications.
3. Designing the Approval Interface
Enhance your app by adding a dedicated approval screen. This screen should include the following UI elements:
-
Approval Buttons: - Approve Button: Confirms the expense. - Reject Button: Declines the expense.
-
Status Field (Optional): - Displays the current approval status. - Updates your data source (e.g., SharePoint list) with the corresponding approval decision.
Navigation to the Approval Screen
For instance, you can use the More button on the main screen to navigate to the approval screen:
Navigate(
Screen4,
ScreenTransition.Cover,
{more: ThisItem.ID}
)
On the approval screen, use an Edit Form and set its DataSource to your expense list (e.g., expense-items
). In the Items property of the form, use the following:
LookUp(
'expense-items',
ID = more
)
4. Implementing Email Notification Logic
Instead of using Power Automate, PowerApps can send email notifications directly. To achieve this, incorporate the Office365Outlook.SendEmail function into your submit button’s OnSelect property.
a. Submit Button – OnSelect Property
Set the OnSelect property with the following formula:
Office365Outlook.SendEmail(
"approver@example.com", // Replace with your approver's email address
"Expense Approval Request",
"An expense request has been submitted and requires your approval. Please check the app for further details."
);
Notify("Approval request sent successfully!", NotificationType.Success);
This code sends an email to your approver and displays a success notification within the app.
5. Logging Approval Decisions
In addition to sending notifications, it’s vital to record the approval decision in your data source. Use functions such as Patch or SubmitForm to update the corresponding record.
a. Approve Button Code Example
For an Approve action, update the ApprovalStatus
field in your SharePoint list:
b. Reject Button Code Example
Similarly, when rejecting an expense:
This approach ensures that every decision is both emailed to the approver and recorded in your system for future reference.
6. Testing the Email-Based Approval Flow
Before deploying, test the integrated approval process thoroughly:
-
Simulate an Expense Submission:
- Submit a test expense entry. - Navigate to the approval screen and click either the “Approve” or “Reject” button.
-
Verify Email Notifications: - Confirm that the approver receives the email with the correct subject and message content.
Example images of test outcomes:
-
Email Request Received:
-
Successful Approval Notification:
-
Updated Approval Status in the App:
7. Summary
In this post, we demonstrated how to integrate an email-based approval process into your Expense App using PowerApps. This approach leverages the Office 365 Outlook connector to send notifications immediately when an expense is submitted, while SharePoint (or another data source) keeps a record of the approval decision. By streamlining the process and eliminating the need for Microsoft Flow, you create a user-friendly, real-time expense management solution.
Fine-tune your design and functionality further to meet your business requirements. With these enhancements, your Expense App not only handles expense entries but also manages approvals efficiently, ensuring a smooth workflow for everyone involved.