How to run a Salesforce scheduled flow monthly (or at any cadence)
A frequent gripe I see on places like Trailhead with Salesforce's Scheduled Flow offering is its flexibility in scheduling. While you can schedule these flows daily and weekly, some business processes need to run more or less often than that. While there aren't any great workarounds to have scheduled flows run more often than daily using Flow (you'd likely pivot to Apex Scheduler with CRON notation at that point), there are some options to allow flows to run less often. The idea, to be explained in the following use cases, is to use formula fields to qualify records individually to get picked up and considered daily for scheduled flow usage.
Use Case 1: I need to run a process against all Opportunities in my org on the first of every month.
Solution: Write a formula of type checkbox named IsFirstOfMonth__c on the Opportunity object to qualify records. The Flow we call would run daily, and only accept records where IsFirstOfMonth__c = true (which only evaluates to true once per month). Here is the formula:
DAY(TODAY())=1 |
On the first of the month when the flow runs, the entry criteria for the Flow will find all of our qualifying Opportunity records. The Flow on all other days of the month (regardless of the number days within the month) will not find records for entry.
Use Case 2: I want to send an email to a small sales team daily with a few Salesforce data points and some motivating words for them. However, I do not want to bother this team with emails on weekends when they are not working.
Solution: Rather than replicating the logic 5 times and scheduling 5 independent Flows weekly, write a Flow-based formula to check if today is a weekday. If it is a Weekday, run your logic to gather your data points and send an email. If it is a weekend, do nothing.
Your flow might look something like this:
And your formula field within your flow would look like this:
Finally, in your decision element, you would simply need to check if isWeekday is true or false and route logic accordingly.
These are two simple examples of how to implement less rigid scheduling patterns for scheduled flows pretty simply! You can use similar setup styles for the following use cases:
- Run a Flow once yearly => Run daily combined with: DAYOFYEAR(TODAY())=1
- Run a Flow once quarterly => DAYOFYEAR(TODAY())=1 || DAYOFYEAR(TODAY())= 92 || DAYOFYEAR(TODAY())= 184 || DAYOFYEAR(TODAY())= 276
- Run a Flow only on weekends => IF(WEEKDAY(TODAY()) = 1 || WEEKDAY(TODAY()) = 7, TRUE,FALSE)