cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Julien2
Kudo Kingpin
Kudo Kingpin

Leave request flow with sharepoint

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!!

1 ACCEPTED SOLUTION

Accepted Solutions
ScottShearer
Most Valuable Professional
Most Valuable Professional

@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

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

26 REPLIES 26
ScottShearer
Most Valuable Professional
Most Valuable Professional

@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

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

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!

@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.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

@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.

@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.

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

 

@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!

@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?

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

@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

@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?

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

@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!

@Julien2 

The issue must be that you aren't getting anything returned by Get Items - that may mean that there is an issue with your OData filter.

In my case, my the person or group column in the dashboard list is EmployeeName. 

Here is my Filer query:

PGOdata.jpg

 

To make this work:

  • My logic assumes that the person who put in the request for leave is the person who is getting the leave - in other words one person cannot enter a leave request for someone else
    • Make sure that the person who entered the leave request has an entry in the dashboard
  • verify that the employee name column in the dashborad list is a person or group column.
  • Create another test Flow with a button and add a get items action for the dashboard list like you did earlier.
    • Make sure that you are referring to the column exactly as it shows in the body
  • Note that I put /EMail after the column name - this is required
  • Make sure that you have single quotes around the column reference as in my screen shot

Please test and let me know how it goes.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

@ScottShearer 

Waiting for you, take your time. Thank you !

Hello again !! @ScottShearer 

 

Yes the problem that i was missing /EMail after the column name in OData filter. Now the BalanceofAnnual column is working perfectly.

 

Last question is it possible to update the AmountofAnnualLeave column in the dashboard to show the Leaving Days requested by the Employee when the request is approved?

 

For example:

  • If an Employee requested 2 days the first time and the request is approved can we update automatically the AmountofAnnualLeave to 2.
  • Again if the same employee requested 3 days the second time and the request is approved the AmountofAnnualLeave will be 2-3.. by - seperated.

How it should be:

CaptureAmount.PNGThank you!!

@Julien2 

In my example, the Amount of Annual Leave column is a string with a default value of None.

I added anothe string variable at the top of my flow called Leave History. 

I set the Leave History variable to the value of AmountofAnnualLeave after the Get items action.

The expression that I used to update the Amount of Annual Leave column in the update items action is:

if(equals(variables('Leave History'),'None'),variables('Leave Days'),concat(variables('Leave History'),'-',variables('Leave Days')))

LeaveExpression.jpg

 

 

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

@ScottShearer 

 

I followed your steps and it works well. But the problem is it shows first the (-), then the number of days it should look like 1 then 1-2 not -2-1..

 

Screenshot what i mean and how it shows:

Capture-.PNG

 

So how it should look like the expression for it shows (1-2-3...).

 

Thank you!

@Julien2 

The default value of Amount of annual leave in my example is None.  Set the column to None and try again.  Also, set the column default value to None.

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

@ScottShearer 

 

The flow works well.

 

Thank you very much for your time. I really appreciate your help. 

@ScottShearer 

Great lesson there. Thanks. Can you show how to take away holidays from the startdate and enddate in the calculation ?

Thanks

 

EK0
New Member

 

 

 

@ScottShearer 

I'm trying to create a vacation request workflow using forms to do the following 

1) Take a Multiple Approval

2) Calculate Vacation Balance for Each Employee

I'm following the above steps , but i can't find the expressions that were used.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (2,484)