Sub topic 11
Choosing which records a scheduled flow processes
This chapter assumes you know the Salesforce data model (objects, fields, records) and can open Flow Builder from Setup. It covers how a schedule-triggered flow decides which records to run on. Schedule timing is covered in the previous chapter.
The start element picks the records
A schedule-triggered flow can run once for each record that matches a filter. You set this in the Start element with two choices:
- Object: the object whose records the flow processes, such as Opportunity.
- Filter conditions: field, operator, and value rows that narrow the records.
At each scheduled run, Salesforce queries the object, applies the filters, and starts one flow interview (a single run of the flow) for each matching record. Inside the flow, the record is available as $Record.
If you leave out the object, the flow runs once with no record context. That setup fits work that does not depend on one record, such as a nightly cleanup done with Get Records and Loop elements.
What the metadata looks like
The Start element is stored as XML. This example selects Opportunities in the Prospecting stage and runs daily.
<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>The filterLogic value and means every filter must be true. You can also choose or, or write custom logic such as 1 AND (2 OR 3).
Filtering well
The filter is evaluated when the run starts, so the selection always reflects the data at that moment. Keep these points in mind:
- Filter in the Start element, not later. A Decision element after the start still runs one interview for every record. A Start filter prevents unneeded interviews from being created at all.
- Use a date or status field to avoid reprocessing. If the flow runs daily and only checks
StageName, it handles the same records every day. Add a condition such asLast_Reviewed__cis before a cutoff, and have the flow update that field. - Compare against fixed values. Start filters accept constants and global values, but not values calculated during the flow.
- Expect large matches. Each matching record counts toward the daily limit on flow interviews and is processed in batches. Narrow filters keep the run small.
flowchart TDThe diagram below shows the sequence.
Common mistakes
- Filtering on a field that the running user cannot read, which gives incomplete results. The next chapter covers run context.
- Forgetting that the filter is rechecked on every run, so records that no longer match are skipped without any message.
- Setting a very broad filter, such as all open Cases, and then hitting limits during the run.
Exercise
A scheduled flow runs nightly on Case records and sends a reminder. Cases stay open for weeks, so the same Cases get a reminder every night. How can you change the Start element so each Case is processed less often?
Show answer
Add a filter on a date field, such as Last_Reminder__c being before a cutoff or empty, and have the flow update that field after sending the reminder. Cases that were reminded recently no longer match the Start filter.