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
Super User
Super User

@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
Super User
Super User

@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

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Our team will be reviewing posts using the new "Copilot Studio" label to ensure we highlight and amplify the most relevant and recent content, so you're assured of high-quality content every time you visit. If you share a post that gets featured in the curated gallery, you'll get a PM in the Community to let you know!The curated gallery is ready for you to experience now, so visit the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community. We can't wait to see what you "cook" up!    

Celebrating a New Season of Super Users with Charles Lamanna, CVP Microsoft Business Applications

February 8 was the kickoff to the 2024 Season One Super User program for Power Platform Communities, and we are thrilled to welcome back so many returning Super Users--as well as so many brand new Super Users who started their journey last fall. Our Community Super Users are the true heroes, answering questions, providing solutions, filtering spam, and so much more. The impact they make on the Communities each day is significant, and we wanted to do something special to welcome them at our first kickoff meeting of the year.   Charles Lamanna, Microsoft CVP of Business Applications, has stressed frequently how valuable our Community is to the growth and potential of Power Platform, and we are honored to share this message from him to our 2024 Season One Super Users--as well as anyone who might be interested in joining this elite group of Community members.     If you want to know more about Super Users, check out these posts for more information today:    Power Apps: What is A Super User? - Power Platform CommunityPower Automate: What is A Super User? - Power Platform Community Copilot Studio: What is A Super User? - Power Platform Community Power Pages: What is A Super User? - Power Platform Community

February 2024 User Group Update: Welcoming New Groups and Highlighting Upcoming Events

It's a new month and a brand-new year, which means another opportunity to celebrate our amazing User Groups!Each month, we highlight the new User Groups that have joined the community. It's been a busy season for new groups, because we are thrilled to welcome 15 New User Groups! Take a look at the list below, shared by the different community categories. If your group is listed here, give this post a kudo so we can celebrate with you!   We love our User Groups and the difference they make in the lives of our Community! Thank you to all the new User Groups, new User Group leaders--we look forward to hearing about your successes and the impact you will leave!   In addition to our monthly User Group spotlight, it's a great time to share some of the latest events happening in our User Group community! Take a look at the list below to find one that fits your schedule and need! There's a great combination of in-person and virtual events to choose from. Also, don't forget to review the many events happening near you or virtually! It's a great time of year to connect and engage with User Groups both locally and online. Please Welcome Our NEW User Groups   Power Platform: Heathcare Power Platform User Group Power Platform Connect Hub Power Platform Usergroup Denmark Mexico Norte- Power Platform User Group Pune Power User Group Sudbury Power Platform User GroupMicrosoft User Group GhanaMPPBLR - Microsoft Power Platform Bengaluru User Group Power Apps:   Myrtle Beach Power Platform User GroupAnanseTechWB PowerApps Copilot Studio: Pathfinders Power Platform Community Dynamics365: Cairo, Egypt MSD 365 Business Central/NAV/F&O User GruopMS Dynamics 365 Business Central LatamCincinnati OH D365 F&O User Group February User Group Events February 2024 Cleveland Power Platform User GroupPortallunsj - Februar 2024Indiana D365/AX February User Group MeetingQ1 2024 KC Power Platform and Dynamics 365 CRM Users Group 

January 2024 Community Newsletter

Welcome to our January Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members. If you're new to the Community, please make sure to follow the latest News & Announcements in each Community and check out the Community on LinkedIn as well! It's the best way to stay up-to-date in 2024 with all the news from across Microsoft Power Platform and beyond.      COMMUNITY HIGHLIGHTS Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, giving (and receiving!) kudos, and consistently providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, make it your New Year's Resolution to be more active in the community in 2024.   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzWarrenBelzPstork1saudali_25LaurensMPstork1stephenrobertLucas001AARON_ClbendincpaytonSurendran_RANBNived_NambiarMariamPaulachanNikhil2JmanriqueriosANBJupyter123rodger-stmmbr1606Agniusstevesmith27mandelaPhineastrice602AnnaMoyalanOOlashynBCLS776grantjenkinsExpiscornovusJcookSpongYeAARON_CManishSolankiapangelesPstork1ManishSolankiSanju1Fubar   LATEST NEWS Power Platform 2024 Release Wave Highlights This month saw the 2024 Release Wave 1 plans for Microsoft Power Platform and Microsoft Dynamics 365- a compilation of new capabilities planned for release between April and September 2024. Click here to read Corporate Vice President Maureen (Mo) Osborne's detailed breakdown of the upcoming capabilities, and click the image below to check out some of the Power Platform 2024 Release Wave 1 highlights.     "What's New" Power Platform Shorts Series This month we also launched our brand-new 'Power Shorts' series on YouTube - a selection of super sweet snapshots to keep you in the loop with all the latest trends from across the Power Platform and beyond. Click the image below to check out the entire playlist so far, and don't forget to subscribe to our YouTube channel for all the latest updates.   Super User In Training (S.U.I.T) It was great to see the Power Platform Community officially kick off Season One of their Super User in Training (SUIT) program this month! Their first meeting saw an amazing turnout of over 300 enthusiastic participants who started their dynamic journey toward becoming Super Users. Huge thanks to Manas Maheshwari, Eric Archer, Heather Hernandez, and Duane Montague for a fantastic kick-off. The first meeting also saw seasoned Super User, Drew Poggemann, share invaluable insights on navigating the #MicrosoftCommunity with finesse. Many thanks to Drew for setting the stage and emphasizing the importance of active engagement and the art of providing thoughtful community solutions. If you want to learn more about the features and benefits of gaining Super User status, click the image below to find out more, and watch this space for more info about Season Two and how you can SUIT UP in the community!     UPCOMING EVENTS Microsoft 365 Community Day - Miami - February 1-2, 2024 It's not long now until the Microsoft 365 Community Day Miami, which will be taking place at the Wolfson Campus at Miami Dade College on 1-2 Feb. 2024. This free event is all about unlocking the full potential of Power Platform, Microsoft 365, and AI, so whether you’re a tech enthusiast, a business owner, or just curious about the latest Microsoft advancements, #M365Miami is for you.   The event is completely free and there will sessions in both English and Spanish to celebrate the vibrant and diverse make-up of our amazing community. Click the image below to join this amazing Community Day in Miami and become a part of our incredible network of learners and innovators!     Microsoft Fabric - Las Vegas - March 26-28, 2024 Exciting times ahead for the inaugural #MicrosoftFabric Community Conference on March 26-28 at the MGM Grand in Las Vegas. And if you book now, you can save $100 off registration! The Microsoft Fabric Conference will cover all the latest in analytics, AI, databases, and governance across 150+ sessions.   There will be a special Community Lounge onsite, interactive learning labs, plus you'll be able to 'Ask the Experts' all your questions to get help from data, analytics, and AI specialists, including community members and the Fabric Customer Advisory Team. Just add the code MSCUST when registering for a $100 discount today. Click the image below to find out more about the ultimate learning event for Microsoft Fabric!     Microsoft 365 Conference - Orlando - April 30 - May 2, 2024 Have you added The Microsoft 365 Conference to your community calendar yet? It happens this April 30th - May 2nd in Orlando, Florida. The 2024 Microsoft 365 Conference is one of the world’s largest gatherings of Microsoft engineers and community, with a strong focus on Power Platform, SharePoint, Azure, and the transition to an AI-powered modern workplace.   Click the image link below to find out more and be prepared to be enlightened, educated, and inspired at #M365Conf24!   LATEST COMMUNITY BLOG ARTICLES Power Apps Community Blog Power Automate Community Blog Copilot Studio Community Blog Power Pages Community Blog Check out 'Using the Community' for more helpful tips and information: Power Apps, Power Automate, Copilot Studio, Power Pages  

Super Users 2024 Season One is Here!

   We are excited to announce the first season of our 2024 Super Users is here! Our kickoff to the new year welcomes many returning Super Users and several new faces, and it's always exciting to see the impact these incredible individuals will have on the Community in 2024! We are so grateful for the daily difference they make in the Community already and know they will keep staying engaged and excited for all that will happen this year.   How to Spot a Super User in the Community:Have you ever written a post or asked for help in the Community and had it answered by a user with the Super User icon next to their name? It means you have found the actual, real-life superheroes of the Power Platform Community! Super Users are our heroes because of the way they consistently make a difference in the Community. Our amazing Super Users help keep the Community a safe place by flagging spam and letting the Community Managers know about issues. They also make the Community a great place to find answers, because they are often the first to offer solutions and get clarity on questions. Finally, Super Users share valuable insights on ways to keep the Community growing, engaging, and looking ahead!We are honored to reveal the new badges for this season of Super Users! Congratulations to all the new and returning Super Users!     To better answer the question "What is a Super User?" please check out this article: Power Apps: What is A Super User? - Power Platform CommunityPower Automate: What is A Super User? - Power Platform Community Copilot Studio: What is A Super User? - Power Platform Community Power Pages: What is A Super User? - Power Platform Community

Did You Attend the Microsoft Power Platform Conference in 2022 or 2023? Claim Your Badge Today!

If you were one of the thousands of people who joined us at the first #MPPC Microsoft Power Platform Conference in 2022 in Orlando--or attended the second-annual conference in Las Vegas in 2023--we are excited to honor you with a special community badge! Show your support for #MPPC Microsoft Power Platform Conference this year by claiming your badge!           Just follow this link to claim your badge for attending #MPPC in 2022 and/or 2023: MPPCBadgeRequest    Want to earn your badge for 2024? Just keep watching our News & Announcements for the latest updates on #MPPC24.

Users online (4,183)