Sub topic 9
Schedule-triggered flows: automation on a timer
This chapter assumes you know the Salesforce data model (objects, fields, records), can navigate Setup, and have built a simple flow in Flow Builder. You should also know that autolaunched flows have no trigger and run only when something calls them. A schedule-triggered flow is different. It starts itself on a timer.
What a schedule-triggered flow is
A schedule-triggered flow is an autolaunched flow that Salesforce starts on a schedule you define. You pick a start date, a start time, and a frequency (once, daily, or weekly). You can also pick an object and filter conditions. At the scheduled time, Salesforce finds the records that match the filters and runs the flow once for each of them.
Typical uses:
- Close cases that have had no activity for 30 days.
- Email owners of opportunities that are still in Prospecting.
- Reset a field on many records every night.
- Run a housekeeping task that touches no records at all.
Because no user is present, the flow cannot use screen elements. It has no screens, no user-facing prompts, and no "current user" interacting with it.
How it differs from other flow types
| Flow type | What starts it | Needs a screen | Typical use |
|---|---|---|---|
| Screen flow | A user (button, page, action) | Yes | Guided data entry |
| Record-triggered flow | A record is created, updated, or deleted | No | React to data changes |
| Schedule-triggered flow | A clock time you configure | No | Batch work at set times |
| Autolaunched flow (no trigger) | Another flow, Apex, or the REST API | No | Reusable logic |
A schedule-triggered flow reacts to time, not to a data change. A record-triggered flow reacts to a change in one record. Use a schedule when the condition is "this has been true for a while" or "do this every night."
The start element
The start element holds the schedule and the record selection. Here is the metadata for a flow that runs daily at 02:00 UTC against Opportunities in the Prospecting stage:
<start>
<filterLogic>and</filterLogic>
<filters>
<field>StageName</field>
<operator>EqualTo</operator>
<value>
<stringValue>Prospecting</stringValue>
</value>
</filters>
<object>Opportunity</object>
<schedule>
<frequency>Daily</frequency>
<startDate>2025-01-01</startDate>
<startTime>02:00:00.000Z</startTime>
</schedule>
<triggerType>Scheduled</triggerType>
</start>Each part has a job:
triggerTypeofScheduledmarks the flow as schedule-triggered.objectnames the object whose records the flow processes.filtersandfilterLogicnarrow those records.schedulesets when and how often the flow runs.
The next chapters cover the schedule and the filters in detail. Here the goal is to see how the pieces fit.
What happens at run time
When the scheduled time arrives, Salesforce queues the run. It then selects the matching records and starts a flow interview for each record. An interview is one running instance of a flow. The record being processed is available in the flow as $Record.
The diagram below shows the sequence.
Three points follow from this model.
- One interview per record. If 5,000 records match, you get 5,000 interviews. Design each interview as if it handles one record, and keep the logic bulk-safe so Salesforce can batch the work.
- The run is asynchronous. Salesforce starts the flow near the scheduled time, not at the exact second. Heavy load can delay it. Do not build logic that depends on running at a precise moment.
- No matching records means nothing runs when you have chosen an object. A flow that picks an object but finds no records ends quietly.
Schedule-triggered flows with no object
You can leave the object empty. The flow then runs once per schedule, with no $Record. Use this for work that does not depend on a record, such as a nightly call to an Apex action or a cleanup using Get Records and a loop that you control yourself.
With no object, you must query the data in the flow, using Get Records, and you then own the bulk design. With an object, Salesforce does the batching for you.
A worked example
Suppose you want to close open cases that have been untouched for 30 days. You have two reasonable designs.
Design A: select the cases in the start element. Set the object to Case. Add filters such as Status not equal to Closed and LastModifiedDate before a date. Then add an Update Records element that sets Status to Closed on $Record. Salesforce runs one interview per matching case.
Design B: no object, with a Get Records and a loop. The flow finds the cases itself, loops over them, and updates the collection in one step. This gives you control over counts and reporting, but you must follow bulk rules yourself.
Design A is simpler and is the usual starting point. Choose Design B when you need to compute something across all records, such as a total count, before you update anything.
The filter on a date needs care. The start element cannot compare a field to "30 days ago" with a built-in function in every case. A common pattern is to add a formula-based filter, or to filter on a field you maintain (such as a checkbox set by another process). Check which operators the start element offers in your org.
Configuring one in Flow Builder
- In Setup, open Flows and choose New Flow.
- Select Schedule-Triggered Flow and choose Create.
- In the Set Schedule panel, enter the start date, start time, and frequency.
- Optionally choose an object and add filter conditions.
- Add your elements: Get Records, Decision, Update Records, and so on.
- Save the flow, then Activate it. A saved but inactive flow does not run.
Common errors
- The flow never runs. The most frequent cause is that the flow is not active. Open the flow and check that the active version is the one you edited. A new version stays inactive until you activate it.
- The start date is in the past. For a recurring flow, Salesforce uses the next occurrence. For a one-time flow, a past date means the flow does not run.
- Time zone confusion. The metadata stores the time in UTC (the trailing
Z). Flow Builder shows the time in your user's time zone. Confirm the conversion before you assume a 2 AM run is local. - Wrong record set. A filter that is too loose can update far more records than intended. Test filters in a sandbox and in a report first.
- Unhandled faults. One failing record fails its own interview, and other interviews continue. Without a fault path, you only find out from the failure email. Chapter material on fault handling covers this.
- Screen elements. Screens and other user-interface elements are not available. Flow Builder does not offer them for this flow type.
Limits to keep in mind
Each flow interview is subject to governor limits, which are caps Salesforce sets on resources such as queries and DML statements. When you use an object, Salesforce groups records into batches, and interviews in a batch share limits. Avoid placing Get Records, Create, Update, or Delete elements inside a loop. The bulk-limits chapter shows the safe patterns. Salesforce also caps how many scheduled flow runs an org can execute per day, so check the current limits for your edition before you design high-volume jobs.
Summary
A schedule-triggered flow is automation driven by the clock. You set a start date, time, and frequency. You optionally pick an object and filters. Salesforce then runs one interview per matching record, asynchronously, without a user. Build it, test it narrowly, activate it, and plan for faults.
Exercise
Your schedule-triggered flow has the object set to Case and filters for open cases. At run time, 800 cases match. How many interviews does Salesforce start, and what does $Record refer to in each?
Show answer
Salesforce starts 800 interviews, one per matching case. In each interview, $Record refers to the single case that interview is processing.
Exercise
You saved a new version of a schedule-triggered flow, but the nightly job still behaves the old way. What is the most likely cause, and how do you fix it?
Show answer
The new version was saved but not activated, so the previous active version keeps running. Open the flow in Flow Builder or the Flows list and activate the new version.
Exercise
You need a nightly flow that counts all stale cases, emails one summary to a manager, and only then updates the cases. Would you set an object in the start element? Explain.
Show answer
No. Leave the object empty so the flow runs once. Use Get Records to collect the stale cases, count them in the flow, send a single email, and then update the collection in one Update Records element. With an object set, each case would run in its own interview and the flow could not produce a single combined count and email.