Hello. In the previous lesson, you designed a Salesforce data model by distinguishing independent lookup relationships from dependent master-detail relationships. That distinction matters immediately here: native roll-up summaries depend on master-detail relationships, while formulas, validation rules, and Flows solve quite different kinds of problems.
This lesson gives you a practical way to select the smallest declarative mechanism that fully meets a requirement. By the end, you should be able to justify a choice in the concise form expected in a developer interview: “I would use X because the requirement needs Y; the alternatives only calculate, block, aggregate, or automate.”
Start by identifying the required outcome
Business requirements often contain familiar verbs, but the verb matters more than the object name.
| If the requirement needs Salesforce to… | First mechanism to consider |
|---|---|
| Display or calculate a value from fields on the record or its parent | Formula field |
| Prevent a save when data violates a rule | Validation rule |
| Aggregate child-record values onto a master record | Roll-up summary field |
| Create, update, delete, route, notify, or schedule work | Flow |
The most common mistake is choosing based on what feels familiar rather than on the required behavior. For example, a formula and a Flow can both appear to “calculate a value,” but their execution models are fundamentally different:
- A formula field derives a value whenever Salesforce needs to display or report it. It does not store or write the calculated result as ordinary record data.
- A Flow is automation: it runs and can perform actions, such as setting a field, creating another record, sending an alert, or waiting until a scheduled time.
Likewise, both a validation rule and a Flow can react when a record changes. But a validation rule acts as a gate: it blocks an invalid save. A Flow acts as a worker: it carries out work before or after a record is saved, depending on its design.
Use this four-part diagnostic before naming a tool:
- Is the desired result a displayed value, a saved-data restriction, an aggregate, or an action?
- Does it involve only the current record, its parent, or a collection of child records?
- Must it happen immediately, or at a later scheduled time?
- Does the requirement need to stop the user, or help the user proceed?
That last distinction is especially important. “Do not allow an invalid subscription” is validation. “When a subscription becomes active, create an onboarding task” is automation.
Formula fields: derive a value; do not change data
Choose a formula field when the requirement says, in effect:
“Show me a value that can always be derived from available data.”
Formula fields can combine fields, operators, and functions. Their result is computed dynamically when a user views the record or includes the field in a report. The formula expression is metadata; Salesforce does not persist a separate manually editable value for the result.
Formula & Roll-Up Summary Fields
Read Salesforce Trailhead’s explanation of formula fields and roll-up summaries. It establishes the crucial difference between a dynamically calculated field and a stored aggregate of child-record data.
In the opening explanation, read the comparison between roll-ups and formulas. Then, in the “Create Additional Formulas” section, scan the average-score example to see how a formula can use values supplied by roll-up fields. Focus on where each value comes from rather than on reproducing the setup clicks.
Good formula-field requirements
In the subscription model from the previous lesson, these are formula-field candidates:
| Requirement | Why formula fits |
|---|---|
| “Show the number of days until a subscription’s contract ends.” | The value derives from Contract_End_Date__c and the current date. |
| “Show whether a subscription is eligible for renewal.” | It is a read-only logical result based on status and date fields. |
| “Show Amount Due as Total Amount minus Amount Paid.” | Both are values on the same parent record. |
| “Display the Account’s customer segment on each Subscription.” | A cross-object formula can display a value from a parent relationship without duplicating it. |
For example, a checkbox formula field named Renewal_Eligible__c might conceptually express:
AND(
ISPICKVAL(Status__c, "Active"),
Contract_End_Date__c <= TODAY() + 90
)
The precise formula is less important than its meaning: it reveals the current eligibility state. It does not update Status__c, create a renewal Opportunity, or notify an account manager. Any of those would require automation.
Formula-field limits that drive better choices
Do not use a formula field when the requirement needs you to:
- preserve the calculated value as a historical snapshot;
- set or update another field;
- create or update another record;
- aggregate an arbitrary collection of child records;
- block an invalid save;
- send a notification or wait until a future date.
For example, “Store the commission rate in effect when the subscription was activated” is not automatically a formula-field requirement. If the rate can later change on a parent Account or related plan, a formula would recalculate the historical record. If the business needs the original value preserved, a Flow may copy the rate into a normal, stored field at activation.
A formula is therefore best thought of as a live lens over existing data, not a business-process engine.
Validation rules: reject an invalid record save
Choose a validation rule when a requirement says:
“A record must not be saved when this condition is true.”
Validation-rule formulas evaluate to TRUE for the bad state. Salesforce then prevents the save and shows the configured error message. The error message is part of the design: it should tell a user what needs correction, not merely announce that a rule failed.
Get Started with Validation Rules - Trailhead - Salesforce
Read this Salesforce Trailhead unit for the model of validation rules as data-quality gates, including the counterintuitive but essential rule that a validation formula returns true for invalid data.
In “Use Cases for Validation Rules,” read the use cases for format, process, and compliance constraints. Then read the “Mechanics of Validation Rules” discussion from the evaluation logic and execution note. Keep the central test in mind: when the formula is true, Salesforce blocks the save.
Good validation-rule requirements
| Requirement | Why validation fits |
|---|---|
| “A subscription cannot be marked Active without an activation date.” | This is an invalid state that must be rejected at save time. |
| “A cancelled subscription must have a cancellation reason.” | It enforces data completeness for a lifecycle stage. |
| “Contract end date cannot be earlier than activation date.” | It prevents an impossible date relationship. |
| “A user cannot change a closed billing record unless they have a specified exception permission.” | It protects an established business state. |
For the activation-date requirement, the validation formula would describe the failure condition:
AND(
ISPICKVAL(Status__c, "Active"),
ISBLANK(Activation_Date__c)
)
A suitable message is: “Enter an Activation Date before setting the subscription to Active.”
Notice why this is better than a Flow that “fixes” the data. There may be no valid date that automation can honestly invent. The correct result is to stop the transaction and request the missing information.
Validation versus field requiredness
A field marked Required is appropriate when it must always be populated for every record creation or edit context covered by that field configuration. A validation rule is more precise when the requirement is conditional:
Cancellation_Reason__crequired only when status is Cancelled;Activation_Date__crequired only when status is Active;- a regulatory identifier required only for a particular country or customer type.
Use a validation rule for cross-field logic, status-dependent completeness, format checks that standard field properties cannot express, and controlled exceptions.
Be careful around automation
Validation rules are not passive documentation. They run during a transaction and can block records changed by users, imports, integrations, Flows, or Apex. The Trailhead unit notes that validation rules execute after relevant automation has run, so a Flow that writes a conflicting value can cause the whole transaction to fail.
That makes the following a practical design discipline:
- write one clear error message per invalid business condition;
- test normal user edits and automated paths;
- avoid overlapping rules that make a legitimate state impossible;
- document intentional bypass conditions, ideally using a custom permission rather than hard-coding a profile name.
The next lesson on order of execution will explain the timing in more detail. For now, treat validation as the transaction’s final quality gate, not as an isolated configuration item.
Roll-up summary fields: aggregate detail records on a master
Choose a roll-up summary field when the requirement says:
“On the parent, show a count, sum, minimum, or maximum based on its related detail records.”
A native roll-up summary is configured on the master object and summarizes records from a related detail object. This is why the relationship decision in the previous lesson is architecturally meaningful.
Return to the Subscription__c and Subscription_Component__c model:
Subscription_Component__cis a dependent detail record;Subscription__cis its master;- a roll-up summary on
Subscription__ccan count components or sum their recurring charges.
| Requirement | Suitable roll-up configuration |
|---|---|
| “Show the number of included components on each subscription.” | Count Subscription_Component__c records. |
| “Show total monthly component charges.” | Sum Monthly_Charge__c on component records. |
| “Show the latest component activation date.” | Maximum of Activation_Date__c. |
| “Count only currently active components.” | Count detail records with a filter such as Status__c = Active. |
The aggregate is maintained by Salesforce when relevant detail records are created, changed, deleted, or moved between masters. You configure the aggregation and, if needed, filter criteria; you do not write looping logic yourself.
The boundary: master-detail is not negotiable just for a total
Native roll-up summary fields are available across master-detail relationships. They are not the native answer for a lookup relationship.
Suppose the business asks:
“Show the total active subscription value on each Account.”
In the previous lesson, Subscription__c had a lookup to Account because subscriptions may have independent ownership, security, and retention needs. You should not convert that relationship to master-detail solely to obtain a roll-up summary. That would change deletion and sharing behavior in ways the business may not want.
Instead, the requirement has become a Flow candidate: a record-triggered Flow can maintain a stored total on Account, provided its design handles relevant create, update, delete, and reparenting cases. Later in the course, you will also see cases where Apex is more suitable for high-volume or complex aggregation.
A useful decision statement is:
Use a roll-up summary when the required aggregation is supported and the child is already a true detail record. Do not reshape the data model merely to make a roll-up available.
Formula and roll-up summary often work together
These tools are complementary, not competitors. Consider an invoice-style subscription balance:
- A roll-up summary calculates
Total_Component_Charge__cfrom child component records. - A normal currency field stores
Amount_Paid__c. - A formula field displays
Amount_Due__cby subtracting the stored payment from the roll-up total.
The roll-up answers, “What do the children total?” The formula answers, “What does this parent-level calculation currently equal?”
Flow: make something happen
Choose Flow when the requirement requires Salesforce to perform an action or orchestrate a process. A Flow can set fields, create or update related records, send notifications, call actions, branch on decisions, and, in appropriate Flow types, run on a schedule or wait.
Ultimate Salesforce Flow Crash Course
Watch “Ultimate Salesforce Flow Crash Course” by Salesforce Ben for a focused comparison of Flow with other declarative and programmatic options.
Watch tool selection. Listen for the boundary between Flow, approvals, and Apex, but keep this lesson’s narrower question in view: choose Flow when the need is to perform work, rather than merely calculate, block, or natively aggregate.
A record-triggered Flow is the usual choice when a create or update to a record should start automation. For example:
“When a Subscription is changed to Active, create an onboarding Case for Operations and set its due date to two business days from now.”
This is not a formula: something must be created.
It is not a validation rule: a valid save is allowed and should initiate work.
It is not a roll-up: no detail-record aggregation is involved.
It is a record-triggered Flow.
The image below shows the same central idea: one record event can have immediate work and work scheduled for a later time.

Good Flow requirements
| Requirement | Why Flow fits |
|---|---|
| “When an Opportunity becomes Closed Won, create a draft contract.” | It creates a related record. |
| “Five days after a customer’s close date, create a welcome task.” | It needs scheduled work. |
| “When a service location changes, update related open installation cases.” | It updates related records. |
| “When a subscription is activated, notify the account team if consent is missing.” | It performs branching and an action. |
| “Maintain an Account’s total active subscription value where Subscription uses lookup to Account.” | It can maintain an aggregate that native roll-up cannot support. |
A practical Flow boundary
Flow is powerful, but “Flow can do it” is not sufficient justification. Prefer the narrower declarative mechanism when it fits:
- Do not use a Flow just to display
Contract_End_Date__c - TODAY(): use a formula field. - Do not use a Flow merely to reject a missing cancellation reason: use a validation rule.
- Do not use a Flow to sum supported detail-record charges where a native roll-up summary does the job.
Choosing the specialized tool is usually clearer, easier to maintain, and less likely to introduce side effects. Select Flow when an actual action, multiple records, branching process logic, or time-based behavior is essential.
A selection method you can use in interviews
When presented with a requirement, restate it in operational terms before choosing a tool.
| Requirement wording | Operational interpretation | Choice |
|---|---|---|
| “Show whether the contract expires within 90 days.” | Derive a read-only current value. | Formula field |
| “Do not permit activation without a service location.” | Reject an invalid save. | Validation rule |
| “Show the total charge of subscription components.” | Aggregate detail records to their master. | Roll-up summary |
| “When activated, create a provisioning request and a follow-up task.” | Create records and coordinate a process. | Flow |
| “Show total active subscriptions on Account, but subscriptions use lookup.” | Aggregate across lookup-related records; native roll-up is unavailable. | Flow, if volume and logic are suitable |
A strong explanation has three components:
- Name the behavior: “This is an aggregation,” or “This must block a save.”
- Name the mechanism: “Use a roll-up summary,” or “Use a validation rule.”
- Rule out the nearest alternative: “A formula cannot aggregate child records,” or “A Flow could block through an added-error design, but a validation rule is the dedicated and clearer mechanism for this rule.”
For a job interview, avoid vague answers such as “I would use Flow because it is low-code.” Instead, connect the mechanism to the specific requirement and its data-model constraints.
Key takeaways
The four declarative mechanisms are easier to select once you focus on what Salesforce must do:
- Use a formula field to display a live calculation derived from available fields. It calculates; it does not perform actions or store a historical snapshot.
- Use a validation rule to stop a record from being saved in an invalid state. Its formula evaluates to
TRUEwhen the record should be rejected. - Use a roll-up summary field to count, sum, find the minimum, or find the maximum across related detail records on a master-detail relationship.
- Use Flow when a record event must cause action: create or update records, send notifications, branch through process logic, or perform scheduled work.
The most useful rule of thumb is: calculate with formulas, protect data with validation, aggregate true detail records with roll-ups, and automate work with Flow.
Next, you will trace a record update through Salesforce’s order of execution. That will make it clearer why interactions among Flows, validation rules, and Apex automation sometimes produce unexpected transaction failures.
Can't find a good explanation? Sign up and we'll make it for you
Sign up