Hi,
I want to create a recurring flow that sends at the start of every Monday that sends an email to myself of the employee's who are off the this specific week. Sunday - Saturday
In the data I have - I do not have a start and end date it just shows a list of dates that have been approved e.g.
In the email I want the dates to show as:
Employee A: 15/08/2021 - 19/08/2021
Employee B: 16/08/2021 - 17/08/2021
Is it possible to capture the dates like this without including all the dates in-between?
I do not want it do show like a string where it says:
[Employee A - 15/08, 16/08, 17/08, etc]
Thank you,
Henry
Solved! Go to Solution.
Hello @DynamicsHS ,
please follow these steps:
1. Initialize a String variable, that will be useful to list the Employees in the email body:
2. Initialize a temporary Array variable, to be used to list the dates as numbers and find min and max values:
3. Initialize an Integer variable, to store the min value:
4. Initialize an Integer variable to store the max value:
5. Add the Excel "List rows present in a table" in order to grab the Employees rows:
6. Add a "Select" action where we want to extract the Employee from the previous array:
7. Add a "Compose" action in which put the following expression, useful to get only unique values from the Select outputs action:
union(body('Select'),body('Select'))
8. Add an "Apply to each" control where add the following actions. The "Select an output from previous steps" field must be filled with the previous Compose outputs action:
In the "Apply to each" settings it's needed to enable the "Concurrency control" and set it to 1.
9. Add a "Filter array" action where we want to filter the excel rows based on the employee name:
10. Add a "Parse JSON" action, in the "Content" field put the Filter array Body. In regards of the Schema section, please first run the flow, copy the Filter array outputs, then click on the "Generate from sample" button and paste the code inside.
11. Add an Apply to each loop, putting the Parse JSON Body. Inside the Apply to each control, add the "Append to array variable", in the Value add the following expression in order to convert the string date in an integer:
int(items('Apply_to_each_2')['Date'])
12. Add a "Set variable" action where select the varMin variable and add the following expression:
min(variables('varNumbers'))
13. Add a "Compose" action putting the following expression, useful to identify the min date from an integer:
addDays('1900-01-01',variables('varMin'),'yyyy-MM-dd')
14. Add a "Set variable" action where select the varMax variable and add the following expression:
max(variables('varNumbers'))
15. Add a "Compose" action putting the following expression, useful to identify the max date from an integer:
addDays('1900-01-01',variables('varMax'),'yyyy-MM-dd')
16. Add the "Set variable" action, in order to set the temporary variable empty:
[]
17. Add an "Append to string variable" action in order to populate the varEmployee variable:
add the Current item: outputs from Compose-MinDate - outputs from Compose-MaxDate followed by the "<br>" code:
18. Outside the Apply to each control, add a "Send an email (V2) action, in the email body add the "varEmployee" variable.
If I have answered your question, please mark my post as Solved.
If you like my response, please give it a Thumbs Up.
BR,
Marco
Hello @DynamicsHS ,
please follow these steps:
1. Initialize a String variable, that will be useful to list the Employees in the email body:
2. Initialize a temporary Array variable, to be used to list the dates as numbers and find min and max values:
3. Initialize an Integer variable, to store the min value:
4. Initialize an Integer variable to store the max value:
5. Add the Excel "List rows present in a table" in order to grab the Employees rows:
6. Add a "Select" action where we want to extract the Employee from the previous array:
7. Add a "Compose" action in which put the following expression, useful to get only unique values from the Select outputs action:
union(body('Select'),body('Select'))
8. Add an "Apply to each" control where add the following actions. The "Select an output from previous steps" field must be filled with the previous Compose outputs action:
In the "Apply to each" settings it's needed to enable the "Concurrency control" and set it to 1.
9. Add a "Filter array" action where we want to filter the excel rows based on the employee name:
10. Add a "Parse JSON" action, in the "Content" field put the Filter array Body. In regards of the Schema section, please first run the flow, copy the Filter array outputs, then click on the "Generate from sample" button and paste the code inside.
11. Add an Apply to each loop, putting the Parse JSON Body. Inside the Apply to each control, add the "Append to array variable", in the Value add the following expression in order to convert the string date in an integer:
int(items('Apply_to_each_2')['Date'])
12. Add a "Set variable" action where select the varMin variable and add the following expression:
min(variables('varNumbers'))
13. Add a "Compose" action putting the following expression, useful to identify the min date from an integer:
addDays('1900-01-01',variables('varMin'),'yyyy-MM-dd')
14. Add a "Set variable" action where select the varMax variable and add the following expression:
max(variables('varNumbers'))
15. Add a "Compose" action putting the following expression, useful to identify the max date from an integer:
addDays('1900-01-01',variables('varMax'),'yyyy-MM-dd')
16. Add the "Set variable" action, in order to set the temporary variable empty:
[]
17. Add an "Append to string variable" action in order to populate the varEmployee variable:
add the Current item: outputs from Compose-MinDate - outputs from Compose-MaxDate followed by the "<br>" code:
18. Outside the Apply to each control, add a "Send an email (V2) action, in the email body add the "varEmployee" variable.
If I have answered your question, please mark my post as Solved.
If you like my response, please give it a Thumbs Up.
BR,
Marco
User | Count |
---|---|
92 | |
44 | |
21 | |
18 | |
16 |
User | Count |
---|---|
137 | |
49 | |
42 | |
37 | |
29 |