{"id":708,"date":"2021-12-24T14:36:35","date_gmt":"2021-12-24T19:36:35","guid":{"rendered":"https:\/\/www.dontpapanic.com\/blog\/?p=708"},"modified":"2021-12-26T14:24:26","modified_gmt":"2021-12-26T19:24:26","slug":"running-a-recurrence-flow-on-weekdays","status":"publish","type":"post","link":"https:\/\/www.dontpapanic.com\/blog\/?p=708","title":{"rendered":"Running a Recurrence Flow on Weekdays Only"},"content":{"rendered":"<p align=\"left\"><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2021\/12\/Recurrence.png\"><img loading=\"lazy\" decoding=\"async\" width=\"240\" height=\"240\" title=\"Recurrence\" align=\"left\" style=\"margin: 0px 10px 10px 0px; border: 0px currentcolor; border-image: none; float: left; display: inline; background-image: none;\" alt=\"Recurrence\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2021\/12\/Recurrence_thumb.png\" border=\"0\"><\/a>Recurrence Triggers are essential for a wide variety of scenarios.&nbsp; They can be used to run a flow on a specific date and time.&nbsp; Or they can be used to run a flow on a recurring schedule, like once a day or once a month.&nbsp; They can even be used in situations where&nbsp; a process needs to run longer than the 30 day timeout limit on flows.<\/p>\n<p align=\"left\">But what if your recurring schedule has exceptions.&nbsp; For example, you might want to run it on the first Monday of each month or only on weekdays.&nbsp; How can we use the recurrence trigger to handle these more complicated scenarios?<\/p>\n<p align=\"left\">One possible solution is to trigger the flow on a simple schedule, like daily, and then test to see if its the right day.&nbsp; If it is proceed with the flow, but if its not just exit.&nbsp; This does work, but it consumes a lot of flow runs that are unnecessary.&nbsp; Not only is this inefficient it may cause an issue with the limits on API calls in a 24 hour period.&nbsp; It would be much better if we could take these conditions into account BEFORE the flow triggers.&nbsp; But we can\u2019t always reach that level of granularity in the trigger configuration itself. But we can if we use the trigger conditions available under settings.<\/p>\n<p align=\"left\">Let\u2019s look at a specific scenario.&nbsp; I want this flow to trigger on each workday of the month. I start out by creating a flow with a trigger set to fire once a day.&nbsp; This will create a flow that runs everyday of the month.&nbsp; So far the trigger will look like this.<\/p>\n<p align=\"left\"><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2021\/12\/RecurrenceTrigger.png\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"194\" title=\"RecurrenceTrigger\" style=\"display: inline; background-image: none;\" alt=\"RecurrenceTrigger\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2021\/12\/RecurrenceTrigger_thumb.png\" border=\"0\"><\/a><\/p>\n<p align=\"left\">Next I need an appropriate filter that will limit the trigger to only fire on Monday thru Friday.&nbsp; If you aren\u2019t familiar with how to write that filter I suggest using a \u2018Filter array\u2019 action to put it together.&nbsp; After adding a \u2018Filter array\u2019 action to your flow fill in the left side of the comparison with the following formula: <\/p>\n<p align=\"left\"><font face=\"Courier New\"><em><strong>dayOfWeek(utcNow())<\/strong><\/em><\/font><\/p>\n<p align=\"left\">That will take the current date and convert it to a number for the day of the week.&nbsp; Monday = 1, Tuesday = 2, etc. Now finish the condition by choosing \u2018is less than or equal to\u2019 in the middle and enter \u20185\u2019 on the right.&nbsp; We haven\u2019t filled in the Array to filter, but since all we want is the formula that\u2019s OK.&nbsp; We\u2019ll be deleting this action after we copy the formula.&nbsp; Your action should now look like this.<\/p>\n<p align=\"left\"><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2021\/12\/filter-array.png\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"230\" title=\"filter array\" style=\"display: inline; background-image: none;\" alt=\"filter array\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2021\/12\/filter-array_thumb.png\" border=\"0\"><\/a><\/p>\n<p align=\"left\">Now comes the trick that makes this worthwhile.&nbsp; Click on the \u2018Edit in advanced mode\u2019 link. The action will now look like the following.<\/p>\n<p align=\"left\"><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2021\/12\/filter-array-advanced.png\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"209\" title=\"filter array advanced\" style=\"display: inline; background-image: none;\" alt=\"filter array advanced\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2021\/12\/filter-array-advanced_thumb.png\" border=\"0\"><\/a><\/p>\n<p align=\"left\">The formula we need is the one highlighted in yellow.&nbsp; Copy that formula to your clipboard and delete the \u2018Filter array\u2019 action.&nbsp; Our finished flow doesn\u2019t actually use it.&nbsp; Now open the settings dialog for the recurrence trigger using the ellipses (\u2026) menu on the trigger. Click the <strong>+ Add<\/strong> link under Trigger Conditions and paste the formula you copied into the textbox that appears.&nbsp; Your Settings should now look like this.<\/p>\n<p align=\"left\"><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2021\/12\/Settings.png\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"443\" title=\"Settings\" style=\"display: inline; background-image: none;\" alt=\"Settings\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2021\/12\/Settings_thumb.png\" border=\"0\"><\/a><\/p>\n<p align=\"left\">You can now click Done and your flow trigger each day if it is a Monday through Friday.&nbsp; It will not trigger on Saturday, day 6, or Sunday, day 7. Using trigger conditions you can fine tune the schedule of your recurrence trigger to only fire when you want it to.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recurrence Triggers are essential for a wide variety of scenarios.&nbsp; They can be used to run a flow on a specific date and time.&nbsp; Or they can be used to run a flow on a recurring schedule, like once a day or once a month.&nbsp; They can even be used in situations where&nbsp; a process &hellip; <a href=\"https:\/\/www.dontpapanic.com\/blog\/?p=708\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Running a Recurrence Flow on Weekdays Only<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112,116,84],"tags":[111,115,121],"class_list":["post-708","post","type-post","status-publish","format-standard","hentry","category-flow","category-power-automate","category-tips","tag-flow","tag-power-automate","tag-recurrence"],"_links":{"self":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/708","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=708"}],"version-history":[{"count":3,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/708\/revisions"}],"predecessor-version":[{"id":712,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/708\/revisions\/712"}],"wp:attachment":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=708"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=708"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}