Introduction
We often need to set Power Automate flows to trigger under specified conditions, and triggering flows at specific times is one aspect of this. Scheduled cloud flows can conveniently set the flow trigger frequency, such as triggering flows monthly, weekly, daily, hourly, by the minute, or by the second. However, for special cases, such as when we want flows to trigger only on weekdays and not on weekends, we need to further set the flow's trigger conditions.
Business Case
For the pending approval items in the ECR list, we need to send reminder emails to the relevant approvers every day. However, we want to send emails only on weekdays and not on weekends. That is, the flow should trigger only on weekdays and not on weekends. How can this be achieved?
Implementation
We will use a scheduled cloud flow and set it to run at 9:00 AM every day.
Next, we will further configure the trigger by cllicking the '...' in the trigger's upper right corner and selecting 'Settings' to open the settings interface.
Power Automate Trigger Setting |
In the trigger conditions, enter @less(dayOfWeek(utcNow()),6), which means the day of the week number should be less than 6.
Click '+ Add' below and enter the second condition @greater(dayOfWeek(utcNow()),0), which means the day of the week number should be greater than 0.
Power Automate Trigger Conditions |
If you need to convert to China Standard Time, use convertFromUtc(utcNow(), 'China Standard Time') instead of utcNow(). That is, enter respectively:
@less(dayOfWeek(convertFromUtc(utcNow(),
'China Standard Time')),6)
@greater(dayOfWeek(convertFromUtc(utcNow(),
'China Standard Time')),0)
Power Automate Trigger Conditions 2 |
Conclusion
Multiple trigger conditions have an 'AND' relationship, so the flow will only trigger when both conditions are met. In this case, the flow will only trigger on weekdays (Monday to Friday) and not on weekends (Saturday and Sunday).
Note, the digit corresponding to the days of the week are as follows:
Digit |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
Day of Week |
Sunday |
Monday |
Tuesday |
Wednesday |
Thursday |
Friday |
Saturday |
0 Comments