Sub topic 2
Screen Flows, Scheduled Work, Approvals, and Apex Triggers
Assume you understand Salesforce objects, fields, records, relationships, and basic Setup navigation. This chapter compares tools that act after users start a process, after records change, or when code is justified.
Screen flows for guided user interaction
A screen flow guides a user through questions and actions. Use screens for structured input, such as collecting details before creating a Case. Screen flows can validate values, branch with decisions, and create or update records.
Scheduled flows for time-based batch work
A scheduled flow starts at a configured time and processes records that match conditions. For example, it can remind owners about Opportunities with no activity for 30 days. Test the query and expected volume before scheduling it.
Approval processes for sign-off steps
An approval process routes a record to one or more approvers. It can lock the record, update fields, and run actions after approval or rejection. Use it when the requirement is formal authorization, not simply an automated update.
| Requirement | Suitable tool |
|---|---|
| Guided input from a user | Screen flow |
| Time-based record processing | Scheduled flow |
| Formal sign-off | Approval process |
| Complex save-time logic | Apex trigger |
Legacy automation and migration
Workflow Rules and Process Builder were earlier declarative automation tools. Salesforce now treats them as legacy choices for new work. Flow provides a more consistent place for record updates, decisions, actions, and debugging.
Plan migration by inventorying each rule, documenting its entry conditions and actions, building an equivalent Flow in a sandbox, and testing bulk updates. Activate the Flow only after comparing behavior and deactivating the old automation.
::: callout note Do not migrate blindly. Several legacy rules may interact, so document their order, field updates, and expected outcomes first. :::
Governor limits and bulk safety
Governor limits restrict database queries, DML statements, CPU time, and other resources in one transaction. Bulk-safe automation handles many records together. Avoid queries or updates inside loops, and test imports as well as single-record saves.
Apex triggers: when code is justified
Use an Apex trigger when Flow cannot express the logic clearly, when complex algorithms or integrations require code, or when precise bulk processing is necessary. A trigger should delegate substantial logic to a handler and remain bulk safe.
trigger AccountTrigger on Account (before insert, before update) {
for (Account acc : Trigger.new) {
if (acc.AnnualRevenue != null && acc.AnnualRevenue >= 1000000) {
acc.Rating = 'Hot';
}
}
}This before trigger changes records in memory, so it needs no DML statement.
::: exercise Q: Which tool fits a requirement to collect user input, then create a Case? A: A screen flow, because it provides guided interaction before performing record actions. :::
::: estimate minutes: 15 :::