0% found this document useful (0 votes)
9 views

Lab 6. Task Overdue

Uploaded by

ravi.thavutu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Lab 6. Task Overdue

Uploaded by

ravi.thavutu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Lab 6.

Task overdue

Author: Serge Luca aka “Doctor Flow”

Updated by: Dattatray-Patil

Learning objective: Controls, manipulation Excel, conditions, Date & time, expressions

Duration: 20 minutes

Scenario: We have an Excel document with a set of tasks, where some of these tasks are overdue. You will
create a Flow that will find all overdue tasks and will send a report of these tasks.

Tasks:
1. Create a new Excel file in your OneDrive for Business that looks like this (use the same columns).
Before adding data in the Deadline column, make sure it is in Text format (otherwise your flows
will crash!).
Task Status in charge Deadline
Feed the cat Started [email protected] 1/1/2021
Call jon Not Stared [email protected] 2/4/2021
Patch sql server Started [email protected] 7/6/2021
Call mum Started [email protected] 6/7/2021
Buy fruits Started [email protected] 8/8/2021
Call Kent Not Started [email protected] 8/8/2021
Buy a Porsche Done [email protected] 1/9/2021

2. If you already have existing data, change the format to Text :


3. Name it Tasks.xlsx
4. Change the value of the in-charge column to your e-mail address and adjust some deadline
value.
5. We want to write a Flow that will loop through all tasks, and that will check if the task is overdue.
To do so, create a new Instant cloud flow and use a Manually trigger a flow as a trigger.
Name it my Overdue Tasks.
6. The Flow needs to connect to the Tasks.xlsx file, so add an Excel Online (Business) – List rows
present in a table action (Not OneDrive !!!) as illustrated below:

7. Set the action properties, as illustrated in the next picture:


8. Let’s loop through all tasks, so we need to add an Apply to each:

9. Select the add a Dynamic value in the Apply to each action:


10. Add a Condition to filter the task where Status is not equal to Done:

Make sure the operator used is “is not equal”.


11. Add a new sub condition that will check if the task is overdue:

a) Click Add:

b) Select Add row:

c) In “Choose a value”, type the expression (ticks(items('Apply_to_each')['deadline'])) and


click Ok:

Since a timestamp is in string format, the ticks expression returns the number of ticks (100
nanosecond intervals) since 1st January 1601. By using ticks, we can compare two different
timestamp values.

d) Select the operator is less than


e) Type the following expression (and click Ok):
12. In the If yes branch, add a new condition where we will check if the due date is overdue:

13. Rename the condition to Check if overdue to provide your Flow with more clarity:

14. Send an email (V2) to the person in charge of this task and fill in the e-mail properties as
following:
a. The To field should get the Excel in charge value
b. The Subject should be: “your task is overdue.”
c. The Body should be:

15. Run the Flow and check your e-mail.


Note: instead of filtering the Tasks with the Status Done in a condition, you can also keep it more
straightforward by using an OData Filter (click on Show advanced options) in the List rows present in a
table action:

Using OData Filter (Filter query) is often considered as a good practice because the data are filtered on
server-side and that can make you Flow running faster by using fewer resources.

Note: oData expressions are case sensitive!

In some cases, filtering data in the Flow itself cannot be avoided. In this case, you can use the Filter Array
action instead of adding conditions.

Try the following code:

Optional

Why did we switch the format of the Deadline column to Text? Because by default it is a number.

Indeed, if we switch the Deadline column type to General and if re-write (or just update) the data our next
flow run will generate an error:
Internally the Deadline field is now a number that give you the number of days between 1899-12-30 and
your specific date. The ticks() function expect a real date, so it fails here. It should be updated with:

ticks(addDays('1899-12-30',int(items(‘Apply_to_each’)['deadline'])))

We need your feedback


Do you want to report an issue or to suggest something? We need your feedback:
https://github.com/Power-Automate-in-a-day/Training-by-the-community/issues

You might also like