web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Leave request flow wit...
Power Automate
Unanswered

Leave request flow with sharepoint

(1) ShareShare
ReportReport
Posted on by 1,710

Hello everyone !

I have 2 lists in SharePoint:
-Leave Request: Contain 3 columns (Title, StartDate, EndDate).
-Employee Leave Request Dashboard: Contain 4 columns (Title,EmployeeName,Amount of Annual Leave, Balance of Annual).


I want to create one flow for both lists:

1. For Leave request:
When the item is created in SharePoint.
-I want to add conditons to check first if the employee request a vacation more than 3 days to send an approval to Manager and HR.
-If the leave request of the employee is less than 3 days i want to send only the email for the HR without sending to Manager.

 

2. For Employee Leave Request Dashboard: (Note: Total of Annual Leaves is 15 days by default).
-Suppose i am the manager or HR and i want to approve the leave request for this employee that he request a vacation for 3 days.

If someone of them approved the Leave request i want to update the Balance of Annual column to show the total for remaining days for his vacation.


-I should subtract the balance of annual (-) the amount of annual. (So If he requested 3 days and the leave request is approved the column will be (15-3) = 12 days).


-If its rejected the balance will remain the same. (15 days).

 

So any suggestion how to build this flow and what are the expressions i have to use to calculate the dates ?

(I am using the dates based on the calendar)(SAME YEAR).

 

Thank you!!

Categories:
I have the same question (0)
  • Verified answer
    ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @Julien2 

    Please take a look at my solution below and let me know if you have any questions.  Dates need to be converted to ticks in order to get the difference in days.

    Any expression that I used can be seen in the comments area.

    LeaveDashboard1.jpgLeaveDashboard2.jpgLeaveDashboard3.jpgLeaveDashboard4.jpgLeaveDashboard5.jpgLeaveDashboard6.jpg

     

     

  • EBMRay Profile Picture
    1,710 on at

    Hello @ScottShearer 

     

    First of all, thanks for your help.


    I have an error in last condition "Update dashboard if approved" with Get_items.

     

    The Get_items should trigger the same empolyee name in Leave Request List and in Employee Leave Request Dashboard list.


    For example: If "Jennifer" created the item in Leave request list, the Get_items should trigger the same employee name in Employee Leave Request Dashboard to update the balance column for the appropriate Employee Name.

     

    Leave Request_LI.jpg

    LeaveRequestDashboard.PNG


    The error details of "Get_Items":

    ActionFailed.PNG


    I have a question about this expression:

     

    div(sub(variables('End Date Ticks'),variables('Start Date Ticks')),864000000000)


    What does 864000000000 means ?

     

    Thanks again!

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @Julien2 

    First, 864000000000 is the numbre of ticks in a day.

    In my example, employee name is a person or group column - you have it as a text column and that is why you see the error.  Your best bet is to use a person or group column in the dashboard rather than a text column.  Otherwise, it will be difficult to link the request to the dashboard.  Also, please note the single quotes around EmployeeName in my query.

     

     

  • EBMRay Profile Picture
    1,710 on at

    @ScottShearer 

     

    Thanks for replying so quickly.

     

    I changed the type of both columns in both lists to "Person or Group" and i edit the flow as below:

     

    CaptureActionFailed.PNG

    But the error remain the same. An action failed. No dependent actions succeeded: Bad Requests:

    Status "400" The expression "flowtesting@test.com eq 'flowtesting@test.com'" is not valid.

    I also tried this way:

    Thisway.PNG

    And i get the following error:

    "$filter": "EmployeeName eq 'flowtesting@.com' "
    "body": {
     "status": 400,
     "message": "Column 'EmployeeName' does not exist. It may have been deleted by another user.\r\nclientRequestId: bb5631ac-786f-4410-8412-98715d403c5b\r\nserviceRequestId: bb5631ac-786f-4410-8412-98715d403c5b"
     }

    The EmployeeName already exist in my list i have no idea why i am getting this error.

     

    I created first a new item with flowtesting email in the dashboard list  with default annual leave number which is 15.

     

    Then i created another new item in the Leave request with the same email flowtesting that he request 5 days. To start the flow.

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @Julien2 

    Did you change the column in the Dashboard to a person or group column?  For my solution to work, you must make it a person or group column.

    The issue with your expression is how you are referencing the employee name column.

    Here is an easy way to see how you should reference the column:

    1. Create a new Flow with a button trigger
    2. After the button, use a SharePoint get items trigger and configure it to get items from the Dashboard list
    3. Run the Flow
    4. Take a look at the run and click on Get items
      1. Go to the body section at the bottom
      2. Look for a reference to your Employee name column - you must refer to the column in exactly the same way as it appears here

    Please let me know the results.

  • EBMRay Profile Picture
    1,710 on at

     

    @ScottShearer 

     

    Yes i have changed in both lists EmployeeName to type of person or group.

     

    After implementing the trigger flow you tell me about now the flow ran successfully after refering to the column in exactly the same way as it appears in the trigger.

     

    But we have another problem now in the last step, the Leave days is not subtracting the BalanceofAnnual to show the remaining days for the specific employee in the dashboard.

     

    Maybe because the column type of BalanceofAnnual is text ? or something wrong with the expressions ?

     

    Here are some screenshots:

    Capturea.PNG

    Remain15.PNG

    In the dashboard the BalanceofAnnual should be 11 but in the above screenshot remain 15.

     

    and here the flow results:

    AfterRunning.PNG

    Thank you!

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @Julien2 

    You're almost there..

    Please post a screen shot of the Flow for the Get items action and everything below it.  Please add any expression that you used to the comments for that action as I did in my example - that will make it easy to see.

    Alos, click on the leave days variable in your run - what value does it show?

     

     

  • EBMRay Profile Picture
    1,710 on at

    @ScottShearer 

     

    So this is a screenshot about how i implemented and i add the expressions in a comment for each action as you did it.

     

    CaptureBelowGet.PNG

     

    In the Leave days the value it shows is 4 which is correct.

     

    CaptureLeaveD.PNG

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @Julien2 

    Before doing anything else, please change the BalanceofAnnual column to a number with no decimals and test again.  If you still have an issue, please follow steps below.

    __________________________________________________________

     

    OK - thanks - I need just a little more help.  Open the run again and click on the actions in the apply to each action after the Get items action.

    In the action where you set the leave balance variable, what is the value?

    Take a look at the update item action - what value is shown for BalanceofAnnual?

    What I need for you to do is to look at that part of the run and see what doesn't look quite right - then we can fix.  Make sense?

     

  • EBMRay Profile Picture
    1,710 on at

    @ScottShearer 

     

    I changed BalanceofAnnual column type to number and i test it but nothing happens.

     

    When i open the run history to check for the values of  Leave balance and BalanceofAnnual those both actions are not clickable to check for the values no idea why.

     

    CaptureNotclickable.PNG

     

    Thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard