Want to build a leave request approval flow? Check out this complete tutorial on how to create a leave request approval flow using Microsoft flow or Power automate.
In this Power Automate leave request flow, we will also calculate the balance leaves from the total leaves of an employee in the Power Automate from a SharePoint list.
If you want to try the flow then download from the link below (scroll down towards the end of the post).
Power Automate Leave Request – Requirement
Here is the complete guide for creating a Leave Request Approval in Power Automate. And the requirements are mentioned below:
- First of all it will be a 2 level leave request approval i.e. once for Manager and anothert for CEO.
- When an employee submit a leave request, he/she will get a notification for submitting the request successfully. And it will go for an approval from the manager.
- Then the request will wait for approval from Manger.
- If the Manger approve or reject the request then it will notify to the applied user and the data with manager’s comments will be updated on SharePoint list.
- If manager reject the request it will not go for approval from CEO. But if the Manger approve the request then it will go for forther approval from CEO which will be the final approval.
- Similarly, if the CEO approve the request it will notify the user and data got updated on SharePoint list. Also, the approval status got updated from Pendig to Approved. Till the final approval the staus is shown as “Pending“.
- After the final approval the total leaves got updated by calculating and deducting the days from the no. of total leave-days.
- If the CEO rejects the approval then the total leave will not deduct and it will remain same.
Let’s have a look at the step-by-step method to proceed with this flow according to our requirements.
First, we will create 2 lists on our SharePoint Site. One list contains employee names and their total leaves. We named it “Leaves“.
|EmployeeName||Person or Group|
Another list named “Leave Request” contains the details of the leave request of an employee who applied for leave. This list contains columns such as:
|Title||Single line text|
|Reason||Multiple lines of text|
|Start Date||Date and Time|
|End Date||Date and Time|
|TotalDays||Calculated (calculation based on other columns)|
|Types of Leaves||Choice|
|Approval Status||Choice(Pending, Approved, Rejected)|
|Manager||Person or Group|
|Manager Comments||Single line of text|
|CEO||Person or Group|
|CEO Comments||Single line of text|
Here we used a calculated column in SharePoint list named “TotalDays” that will calculate the total leave days from the start date to the end date. For this the formula is:
TotalDays = IF(OR(ISBLANK([Start Date]),ISBLANK([End Date])),"",DATEDIF([Start Date],[End Date],"D"))
Now we will create a flow where all the process goes automatically. First, we will open the Power automate (https://flow.microsoft.com/). Then click on ‘+Create‘ and select ‘Automated cloud flow‘.
Then it will open a page, where we have to give a name to our flow and it will ask us to choose the flow’s trigger. So here we will choose trigger “When an item is created ” and click on Create.
After clicking on Create, we can see it will add a trigger on power automated flow. Here we have to add our SharePoint site address and list name.
After then, we will see how to get data for a login user or applied user from the Leaves list. According to that, we can calculate the balance leaves from the total leaves for that particular user.
For this first, we will add the action “initialize variable” to convert the email id into the string.
Again we will add another action to get the data from the leaves SharePoint list and then filter the data from the whole data. For this, we will add “Get items“.
On that action, there is an option as “Filter Query” where we will use the above variable with the below formula, which will filter the data according to who created the item. The expression is:
EmployeeName/EMail eq 'varLoggedinUserEmail'
Then we will add a compose action, in that we will add the output of the get items i.e. Created by email. It refers to the email address of the user who created the item in the SharePoint list.
In the next step, we will add a compose action to avoid the decimal number and convert the total days into the whole number. For this, we have to add 2 compose actions.
In the first compose we will take “TotalDays” (the calculated column from the Leaves Request SharePoint list) as input.
In the second compose action, we will insert an expression that converts the output of the first compose into an integer. For this, the expression is:
Now we will see how to update the total leaves after taking the total days of leave.
For this, again we will add compose action to convert the “Total Leaves” as an input and then add another compose action to convert the previous compose’s output into an integer.
To convert into an integer, the expression is:
Then we will add another compose action when we will subtract the ‘Total Days ‘ from ‘Total Leaves’.
For subtracting, the expression is:
Then we will add an action “send an email” that will notify the user, that his request has been successfully submitted:
Note: Here we have used the outputs of Compose 2 as Days. That will show the total days from the start date to the end date.
After getting the successful message, the request will go to the Manager and it will wait for approval. Here if the manager approves or rejects the request, then it will notify the user and the data will update on the SharePoint list with the responses of the Manager.
Also, the request will go for further approval i.e. from the CEO. If the manager rejects the request then it will not go to the CEO’s approval. The Approval status( in Leaves Request ) will update as “Rejected”.
As per our requirements, if the Manager approves the request then it will go for further approval from the CEO which will be the final approval.
On the “If Yes” section, again we will add an action to wait for approval from the CEO, and then the user will get notification about responses from the CEO. Similarly, the data got updated on the SharePoint list.
Once the request got approved by the CEO, TotalLeaves will deduct according to the requested total days of leaves. Also, it will calculate the Total Leaves and update the rest leaves on SharePoint List(i.e. Leaves). For this, here we will add another action as “Update item“.
Here we use the outputs of composing 7 (subtraction of TotalDays from TotalLeaves) that will update on the leaves and show the rest of the balance leaves of the applied use.
Now just save the flow. And we can see the flow is now ready to Run.
Test the Leave request flow
Let’s have a look at the below implementation. For example, a user adds a leave request on the leaves request list.
After adding the request, the user will get a success message like the below:
We can see, the request is automatically forwarded to the manager. Also, it will ask for Approve or Reject to the manager like below:
After approval by the manager, we can see the user will get a notification about it.
And the Sharpoint list will update according to the Manager’s response.
Similarly, after approval from the Manager, the request will be forwarded to the CEO automatically for final approval. The CEO will get an email like the below:
After approval by the CEO, again the user will get a notification through email about it:
Now we can see the Approval status got updated from Pending to Approved. Also, the CEO Comments column got updated.
Also, we can see the TotalLeaves got updated on the Leaves SharePoint list. Before it was 14 but now it will be showing as 11 as it is deducted by 3(Total Days).
In this way, we can implement the multi-level Leave request approval on Power Automate flow and can calculate the data on SharePoint List. You can download this flow from here.
Calculate Half-day in Power Automate leave application
Now we will see how to calculate the Half-day leave on leave request SharePoint list and how to update the total leaves of an employee according to Half-day calculation.
Here is the step-by-step guide to doing this calculation on SharePoint and PowerAutomate flow:
First, we will add a calculated column on our SharePoint list named “Total_Days“. For this, the expression is:
Here we used “TotalDays” that we have created previously to calculate the total days from start day to end date.
Now we can see when a user applied for a leave including half days then it will appear like this:
Now we will do a Lil modification on our Power Automate flow. Such as we will convert the Total_Days into float type. For this, the expression is:
Similarly, we will convert the “Total Leaves” into float again. For this, the expression is:
Then just save the flow and re-run it again. We can see is the “Total_Days” (new calculated column in Leaves Request) appear like below and here we hid the “Total Days“(the previous calculated column):
And the “Total_Leaves” (in Leaves list) got updated according to half-day calculation after the final approval:
This is how we can calculate the half-day leave request on the Power automate flow and SharePoint list.
Download flow for Leave Request
Download power automate leave request flow and also make sure to create both the SharePoint lists with the required list.
In this flow tutorial, we learned how to create a leave request approval flow using Microsoft flow or Power Automate.
Related Power Automate tutorials:
- How to move files from OneDrive to SharePoint using Power Automate
- Scheduled cloud flow Example
- Power Automate Delete all items in SharePoint list
- PowerApps upload file to SharePoint document library
- Save my email attachments to a SharePoint document library Power Automate or Flow
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site EnjoySharePoint.com