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!!
Solved! Go to Solution.
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.
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.
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.
The error details of "Get_Items":
I have a question about this expression:
div(sub(variables('End Date Ticks'),variables('Start Date Ticks')),864000000000)
What does 864000000000 means ?
Thanks again!
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.
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:
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:
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.
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:
Please let me know the results.
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:
In the dashboard the BalanceofAnnual should be 11 but in the above screenshot remain 15.
and here the flow results:
Thank you!
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?
So this is a screenshot about how i implemented and i add the expressions in a comment for each action as you did it.
In the Leave days the value it shows is 4 which is correct.
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?
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.
Thank you!
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:
To make this work:
Please test and let me know how it goes.
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:
How it should be:
Thank you!!
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')))
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:
So how it should look like the expression for it shows (1-2-3...).
Thank you!
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.
The flow works well.
Thank you very much for your time. I really appreciate your help.
Great lesson there. Thanks. Can you show how to take away holidays from the startdate and enddate in the calculation ?
Thanks
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.
Check out new user group experience and if you are a leader please create your group
See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.
User | Count |
---|---|
45 | |
42 | |
41 | |
41 | |
32 |
User | Count |
---|---|
84 | |
84 | |
59 | |
50 | |
42 |