Sub topic 3
Entry Conditions and Run Frequency
This chapter assumes you can open Flow Builder and use its main elements. It also assumes you can read a Salesforce formula and know that a save happens inside a database transaction. The previous chapter covered picking the object and trigger event. This chapter covers the next decision: which of those saves should start the flow, and how often a single record may start it again.
Why entry conditions matter
A record-triggered flow starts for every save that matches its object and trigger event. Without further filtering, a flow on Opportunity "created or updated" runs for every edit to every Opportunity. Most of those runs would find nothing to do.
Entry conditions decide whether the flow starts at all. A save that fails the conditions never creates a flow interview, so it uses no flow resources. The same check done with a Decision element at the top of the flow still starts an interview first. Filtering at the entry point is cheaper and makes the flow's intent clear to the next admin who opens it.
There are two settings to configure:
- Entry conditions: which records qualify.
- Run frequency: for an update, whether the record must newly meet the conditions, or whether any qualifying save counts.
Choosing a condition requirement
Under "Set Entry Conditions", the Condition Requirements picker offers four choices.
| Option | What it does | Use it when |
|---|---|---|
| None | The flow starts on every matching save | The flow really applies to every record |
| All Conditions Are Met (AND) | Every condition row must be true | You have simple field filters |
| Any Condition Is Met (OR) | At least one row must be true | Several alternative triggers apply |
| Custom Condition Logic Is Met | You write logic such as `1 AND (2 OR 3)` | You need mixed AND/OR |
| Formula Evaluates to True | You write one Boolean formula | You need functions, `ISCHANGED`, or related fields |
Each condition row has a resource (usually a field on {!$Record}), an operator, and a value. Rows are quick to build and easy to read. Use a formula when a row cannot express the rule.
Formula entry conditions
A formula entry condition must return true or false. The formula can use functions such as AND, OR, ISBLANK, ISCHANGED, ISNEW, and PRIORVALUE. It can also follow relationships from {!$Record}, for example {!$Record.Account.Industry}.
This example lets an Opportunity update start the flow only when its stage has just changed to Closed Won:
AND(
ISCHANGED({!$Record.StageName}),
{!$Record.StageName} = "Closed Won"
)ISCHANGED compares the value being saved with the value before the save. Without it, the stage check alone would be true for every later edit to a Closed Won Opportunity.
Rows versus formulas
| Aspect | Condition rows | Formula |
|---|---|---|
| Readability for non-developers | High | Lower |
| Detecting a change | Needs run frequency setting | `ISCHANGED` or `PRIORVALUE` |
| Cross-object values | Limited | Full formula syntax |
| Typos | Picker prevents most | Caught only at save or at test time |
Prefer rows when they are enough. Switch to a formula when the rule involves change detection, several functions, or related-object fields.
Run frequency
Run frequency appears only when the trigger is "A record is updated" or "A record is created or updated". It answers this question: when a record is updated and still meets the conditions, should the flow run again?
There are two choices:
- Only when a record is updated to meet the condition requirements: the flow runs when the record did not meet the conditions before the save and does now.
- Every time a record is updated and meets the condition requirements: the flow runs on every qualifying save.
How the "only when" option works
Salesforce evaluates the conditions against the prior version of the record and against the new version. The flow runs only if the prior version failed and the new one passes. A newly created record counts as a record that did not previously meet the conditions, so a create that satisfies them also runs the flow.
Take the entry condition {!$Record.Amount} > 100000 with "only when":
| Save | Prior Amount | New Amount | Flow runs? |
|---|---|---|---|
| Create | none | 150,000 | Yes |
| Update | 50,000 | 150,000 | Yes |
| Update | 150,000 | 160,000 | No, it already met the condition |
| Update | 150,000 | 80,000 | No, it no longer meets it |
| Update | 80,000 | 150,000 | Yes, it newly meets it again |
The last row matters. The record can re-enter the flow if it drops out of the condition and later returns to it.
With "every time", the third row would also run the flow. Pick it when the work must repeat on each qualifying edit, for example recalculating a value that depends on other fields. Make sure the flow is safe to repeat. A flow that creates a Task each time would create a duplicate on every edit.
Default and effect on recursion
For a flow that runs on update, "only when" is the safer choice and the usual one. It limits unneeded runs and reduces the chance that a flow's own update triggers it again. Recursion is covered in a later chapter. For now, note that entry conditions and run frequency are your first line of defense against it.
Create-only and delete triggers
If the trigger is "A record is created" or "A record is deleted", no run frequency setting appears. A record is created once and deleted once, so there is nothing to repeat.
Entry conditions with before-save and after-save
Entry conditions work the same way for both optimizations, but they are evaluated at different moments. In a before-save flow, the conditions are checked against the record as it enters the save, before the flow's own changes. In an after-save flow, the record has already been written to the database but not yet committed.
Here is a before-save flow that uses a simple row condition and "only when":
Flow: Opportunity - Set Next Step (before-save)
Object: Opportunity
Trigger: A record is created or updated
Optimize for: Fast Field Updates
Entry condition: {!$Record.Amount} > 100000
Run: Only when a record is updated to meet the condition requirements
Assignment element
Variable: {!$Record.NextStep}
Operator: Equals
Value: Review large dealAnd an after-save flow with a different condition:
Flow: Opportunity - Create Follow-up Task (after-save)
Object: Opportunity
Trigger: A record is created or updated
Optimize for: Actions and Related Records
Entry condition: {!$Record.StageName} = "Closed Won"
Run: Only when a record is updated to meet the condition requirements
Create Records element (object: Task)
Subject: Send welcome package
WhatId: {!$Record.Id}
OwnerId: {!$Record.OwnerId}With "only when", the Task is created once when the Opportunity reaches Closed Won. Later edits to the closed Opportunity do not create more Tasks.
Common errors
Checking the value but not the change
An entry condition of {!$Record.StageName} = "Closed Won" with "every time" runs on every save of a Closed Won record. Use "only when", or add ISCHANGED in a formula.
Expecting "only when" to remember history
The check compares only the prior and new versions of one save. It does not remember that the flow ran last month. If a record leaves the condition and returns, the flow runs again. If the work must happen exactly once for the life of the record, store a flag field and include it in the condition, for example {!$Record.Welcome_Sent__c} = false.
Using `ISCHANGED` on create
On a create, ISCHANGED is false for fields in a way that can surprise you. Test create and update paths separately. If the flow must handle both, use OR(ISNEW(), ISCHANGED({!$Record.StageName})).
Moving checks into the flow body
A Decision element at the top of the flow works, but it starts an interview for every save. Keep filtering that you can express as a condition in the entry conditions.
Forgetting that other processes also save
Integrations, data loads, and Apex DML all trigger the flow. A condition such as "Owner changed" will fire for an owner reassignment from a bulk tool as well as a user edit. Design for all sources.
A decision flow for configuration
Verifying the behavior
A quick way to confirm the condition works is an Apex test that saves a record and checks the result. This test assumes the before-save flow above is active. It checks that inserting a large Opportunity leaves NextStep set by the flow.
@IsTest
private class OpportunityFlowTest {
@IsTest
static void beforeSaveFlowSetsNextStep() {
Opportunity opp = new Opportunity(
Name = 'Large deal',
StageName = 'Prospecting',
CloseDate = Date.today().addDays(30),
Amount = 200000
);
insert opp;
Opportunity saved = [SELECT NextStep FROM Opportunity WHERE Id = :opp.Id];
Assert.areEqual('Review large deal', saved.NextStep);
}
}Add a second test with an Amount of 50,000 and assert that NextStep stays blank. A test that proves the flow does not run is as valuable as one that proves it does.
Summary of rules
- Filter in the entry conditions, not in a Decision element at the top.
- Use rows for simple filters and a formula for change detection or related fields.
- Use "only when a record is updated to meet the condition requirements" unless the work must repeat.
- Make repeating flows safe to run many times.
- Use a flag field when work must happen only once.
Exercise
A flow on Case runs on create or update. The entry condition is {!$Record.Priority} = "High" and the run frequency is "Only when a record is updated to meet the condition requirements". A Case is created with Priority Medium, edited to High, edited again (still High), changed to Low, then changed back to High. On which saves does the flow run?
Show answer
It runs on the edit to High and on the final change back to High. It does not run on the create, because Priority was Medium. It does not run on the second edit, because the record already met the condition. It does not run on the change to Low, because the record no longer meets the condition.
Exercise
You need a flow that sets a field every time an Account's AnnualRevenue changes, and only when the new value is above 1,000,000. Which condition type and run frequency do you choose, and why?
Show answer
Use "Formula Evaluates to True" with AND(ISCHANGED({!$Record.AnnualRevenue}), {!$Record.AnnualRevenue} > 1000000), and set the run frequency to "Every time a record is updated and meets the condition requirements". ISCHANGED limits runs to saves that change AnnualRevenue. "Every time" is needed because a change from 2,000,000 to 3,000,000 keeps the record meeting the condition, and "only when" would skip it.