A few days ago, I developed a dashboard for the employee leave request application in Power Apps. The dashboard contains all employees’ leave requests and is accessible only to admins who approve or reject them.
Mail must be sent to the requester once the admin approves or denies the request. So, I achieved this with Power Apps button control without using Power Automate flow.
In this article, I will show you how to send approval email using Power Apps button control.
Send Approval Email Using Power Apps Button
The example below shows that whatever item I selected in the gallery is displayed in the form control. Once I click on the approve button, the status of the selected item is updated, and an email is sent to that employee, which works the same way for rejecting the leave request.
I used the SharePoint list Employee Leave Request below in the Power Apps application.
Column Name | DataType |
---|---|
Leave Title | Title |
Employee Name | Person |
Leave Type | Choice(Sick Leave Compensation Leave Vacation Leave) |
Leave Start Date | Date&Time |
Leave End Date | Date&Time |
Manager Name | Single line of text |
Approve Status | Choice(Approved Rejected No Status Yet) |
Follow the steps below to achieve this!
1. In Power Apps, connect with the SharePoint list and Office365Outlook from the Data section in the left navigation.
2. Add a Power Apps Gallery control to the new screen and provide the formula below in its Items property.
'Employee Leave Request'
3. Add an Edit Form to the same screen, connect it with the SharePoint list, and then provide the formulas below to the given properties.
DataSource = 'Employee Leave Request'
Item = gal_empLeaves.Selected
DefaultMode = FormMode.View
4. Add two button controls for approving and rejecting the leave request. Then, add the formula below to the OnSelect property of the approve button.
Patch('Employee Leave Request',LookUp('Employee Leave Request',ID=gal_empLeaves.Selected.ID),{'Approve Status':{Value:"Approved"}});
Office365Outlook.SendEmailV2(
gal_empLeaves.Selected.'Employee Name'.Email,
"Your "&gal_empLeaves.Selected.Title&"Request Approved by Manager",
"Dear "&gal_empLeaves.Selected.'Employee Name'.DisplayName&"," & Char(10) &"Your leave request has been approved."
)
Here, using the Patch() function, I’m updating the status value to “Approved” for the selected item in the gallery.
Then, I’m sending an email to the employee using the Office365Outlook connection and SendEmailV2() method.
- Employee Leave Request = SharePoint list name
- ID = SharePoint list id field name
- gal_empLeaves = Gallery name
- Approve Status = Sharepoint list field name
- Employee Name = SharePoint list field name
- Char(10) is used to write sentences in the new line
5. Provide the formula below in the OnSelect property of the reject button.
Patch('Employee Leave Request',LookUp('Employee Leave Request',ID=gal_empLeaves.Selected.ID),{'Approve Status':{Value:"Rejected"}});
Office365Outlook.SendEmailV2(
gal_empLeaves.Selected.'Employee Name'.Email,
"Your "&gal_empLeaves.Selected.Title&"Request Rejected by Manager",
"Dear "&gal_empLeaves.Selected.'Employee Name'.DisplayName&"," & Char(10) &"Your leave request has Rejected."
)
Here, we updated the status value to “Rejected” and emailed the employee to explain why we rejected the leave request.
Save changes and preview the app. The image below shows you will receive an email notification after clicking the approve or reject buttons.
I hope you understand how to send an approval email from Power Apps. After updating the approvals, you can follow this article to try to send an email directly from the approval mail.
Also, you may like:
- Power Apps hyperlink button control
- Create Status Indicator Using Power Apps
- Power Apps show hide buttons based on the current user
- Power App’s modern link control
- Power Apps email attachment control
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com