Skip to content

Automation

Automating with Salesforce Flow

Automate processes without code, with full control.

Reading time
9 min
Published
Updated
All articles

What does automation mean in Salesforce?

Automation in Salesforce is about reducing manual work by letting processes run automatically. Instead of an employee manually sending an email, updating a field, or creating a task, Salesforce does this automatically based on rules you set up.

Flow works like traffic lights for data. Just as traffic lights control traffic based on fixed rules (green = go, red = stop), Flow controls what happens to your data based on conditions you define.

What is Salesforce Flow?

Salesforce Flow is the modern standard for automation within Salesforce. It's a powerful tool that lets you build complex business processes without writing code. Using a visual interface, you drag elements together and determine how data flows through your system.

A Flow consists of different steps that execute one after another. Each step can retrieve data, modify it, make decisions, or interact with users. Together, these steps form a process that runs automatically when certain conditions are met.

Pascal van de Braak working in the Salesforce Flow Builder
Working in the Flow Builder: every block on the canvas is a step in the process.

Types of Flows

  • Record-Triggered Flow. Starts automatically when a record is created, updated, or deleted. Ideal for automatic actions after changes.
  • Screen Flow. Shows screens to users to enter data or make choices. Perfect for guided processes.
  • Scheduled Flow. Runs at fixed times, for example every night or monthly. Useful for recurring batch updates.
  • Autolaunched Flow. Called from other processes, such as Apex or another Flow. Used for reusable logic.

Example: Website Lead Request (Screen Flow)

A Screen Flow that processes a request from the website: from filling out a form to creating a Lead and sending a notification. These are the steps, in the order the flow runs them.

StepElement typeWhat happens
1. Contact formScreenThe visitor enters first name, last name, email address and company name.
2. Check inputDecisionIf the email address is valid and the required fields are filled in, the flow continues. Otherwise the visitor goes back to the form.
3. Find existing LeadGet RecordsThe flow checks by email address whether this person already exists as a Lead. In this example, they don't.
4. Create LeadCreate RecordsThe flow creates a new Lead, with Website as the lead source.
5. Send notificationApex ActionAn Apex class notifies the owner about the new Lead.
6. ConfirmationScreenThe visitor sees a thank-you message for the request.

When do you use Flow?

Salesforce has had several automation tools over the years. Process Builder and Workflow Rules were widely used before, but Salesforce now recommends Flow for all new automation. Flow can do more than those older tools, and new features only arrive in Flow.

Note: Process Builder and Workflow Rules

Existing Process Builders and Workflow Rules still run, but Salesforce no longer supports them. Build new automation in Flow, and have existing processes moved to Flow step by step.

Flow is suitable when you:

  • Want to execute actions when a record is created or modified
  • Need complex logic with multiple conditions and decisions
  • Want to retrieve or update related records
  • Want to guide users through a process with screens and choices
  • Want to automate recurring tasks at fixed times

The key Flow elements

You build a Flow from different elements. Each element has a specific function. Below we explain the most commonly used elements.

Get Records (Retrieve data)

With this element you retrieve existing records from your database. You set conditions to determine which records you want to retrieve, for example "all Opportunities with status 'Open' and owner is current user".

Practical example: You want to retrieve all open tasks from an Account when that Account's status changes to "Inactive".

Get Records: Retrieve tasks where
- Account = current Account
- Status = 'Open'
- Then: close all retrieved tasks

Create Records

With this you create new records. This can be a single record or multiple records at once. You determine which fields you want to fill with fixed values or with information from other parts of your Flow.

Practical example: When an Opportunity reaches the "Closed Won" stage, automatically create a Project record with that Opportunity's data.

Create Record: Project with
- Name = Opportunity.Name
- Account = Opportunity.Account
- Start Date = Today
- Owner = Opportunity.Owner

Decision

The Decision element is the heart of your logic. With it you split the Flow into different paths based on conditions. Think of "if this is true, do that, otherwise do something else".

Practical example: When a Case is created, determine which action to take based on urgency.

Decision: Check urgency

Path 1: if Priority = 'High'
- Assign to senior support employee
- Send immediate notification

Path 2: if Priority = 'Medium' or 'Low'
- Assign to support queue
- Send standard notification

Update Records

You use this element to modify existing records. You can update the record that started the Flow, or records you previously retrieved with Get Records.

Practical example: Update the Account record when a linked Opportunity is won, by updating the "Last win date" field.

Update Record: Account with
- Last_Win_Date__c = Today
- Total_Revenue__c = current value + Opportunity.Amount

Assignment (Set variables)

With Assignment you can store values in variables that you use later in the Flow. This is useful for calculations or to temporarily hold information.

Practical example: Count the number of won Opportunities and store this number to use later in an email notification.

Assignment:
- Variable: TotalOpportunityCount
- Action: Add 1
- Use later in: Email message ("You now have TotalOpportunityCount won deals")

Loop (Repeating actions)

A Loop goes through a collection of records one by one and executes the same actions for each record. This is essential when you want to process multiple related records.

Practical example: Loop through all contacts of an Account and update their preferred language when the Account's language changes.

Loop: Through all Contacts of the Account
- For each Contact:
  Update Contact.PreferredLanguage = Account.Language
- Continue until all Contacts are processed

Apex Action (advanced logic)

Sometimes Flow alone won't get you there, for example when you need complex calculations, integrations with other systems, or logic with multiple objects. In that case you use an Apex Action. This is a piece of code (Apex Class) that you can call from Flow to perform specific actions that aren't possible in Flow itself.

Practical example: Suppose you want to retrieve customer data via an external API or calculate a lease price with multiple parameters. You can have such a calculation executed in Apex and then use it in your Flow via an "Apex Action". You pass the required input values (e.g. customerId or vehicleType), and receive the result as a variable.

Example: you use a fictional Apex class that calculates a monthly price. In your Flow you add the Apex Action element, select the relevant class, fill in the input fields and store the result in a Flow variable.

A concrete example is the free AddressSplit Apex, which splits street, house number and suffix. Whether to build something in Flow or solve it with Apex is covered in When to use Apex and when to use Flow.

Subflow (reusing logic)

Sometimes you use the same automation step in multiple flows. Instead of copying that logic everywhere, you create one autolaunched flow and call it as a subflow. This keeps your org organized and you only need to make changes in one place.

Practical example: Reuse a welcome procedure after creating or updating an Account.

1) Create autolaunched flow "Account Welcome Procedure":
   - Retrieve Account based on passed Id
   - Create task for the owner
   - (Optional) Send email

2) In your record-triggered flow on Account: add "Subflow" element
3) Pass Account Id as input
4) Changes? Only modify the subflow (e.g. task after 5 instead of 3 days)

What a subflow gives you:

  • less duplicate logic in your org
  • easier maintenance
  • flows remain shorter and more readable
  • one place for error handling or logging

Screen (User interaction)

Screen elements are shown to users to collect information or let them make choices. This is only available in Screen Flows and is perfect for guided processes.

Practical example: Show a screen to the salesperson to enter additional information before an Opportunity is converted to a Project.

Screen: "Project details"
- Field: Desired start date (date)
- Field: Project type (dropdown)
- Field: Notes (text field)
Then: use these values to create the Project

Practical example: Status update with notification

Let's work through a concrete example: when an Opportunity's status changes to "Closed Won", we want to send a notification to the related Account's owner and update a field on the Account.

  1. Start the Flow
    • Trigger: Record-Triggered Flow on Opportunity
    • When: Record is updated
    • Condition: StageName changes to "Closed Won"
  2. Retrieve the Account
    • Get Records: Retrieve the Account where Id = Opportunity.AccountId
    • Save as: variable "RelatedAccount"
  3. Check if Account exists
    • Decision: Is RelatedAccount not empty?
    • Yes: continue with the next steps
    • No: stop the Flow (safety measure)
  4. Update the Account
    • Update Records: RelatedAccount
    • Update field: Last_Opportunity_Won__c = TODAY()
    • Update field: Won_Deal_Count__c = current value + 1
  5. Send notification
    • Action: Send email
    • To: RelatedAccount.OwnerId
    • Subject: "New won deal at " + RelatedAccount.Name
    • Message: "Congratulations! The opportunity [Name] was won with a value of [Amount]."
The logic explained

If Opportunity's StageName changes to "Closed Won",
Then retrieve the related Account,
And update two fields on that Account,
And send an email to the Account owner.

Best Practices for Flow

To keep your Flows organized, reliable, and maintainable, there are several important guidelines.

1. Use clear names

Give your Flow, variables, and elements recognizable names that immediately make clear what they do.

  • Good: "Account - Notification on won Opportunity"
  • Good: "varAccountOwner", "getRelatedContacts"
  • Bad: "Flow1", "var1", "Get Records 3"

2. Test with Debug

Use the Debug function to test your Flow step by step before activating it. This way you see exactly which values flow through where.

In the Flow Builder, click "Debug" in the top right, fill in test values, view the output of each element and check that everything works as expected.

3. Protect against empty values

Always check if fields or records exist before using them. An empty value (null) can crash your Flow.

Put a Decision element in front of it: if the variable has a value, continue. If it is empty, stop or use a default value. For example, check that Account.Owner has a value before you send an email.

4. Use Subflows for reusable logic

When you use the same logic in multiple Flows, build a Subflow (Autolaunched Flow) that you can call. This makes maintenance easier.

Example: Subflow "Send welcome email"
- Input: Contact Id
- Action: Retrieve Contact, retrieve template, send email
- Output: Success (true/false)

You can call this Subflow from multiple Flows that need to send a welcome email

If several record-triggered flows run on the same object, set the order with Flow Trigger Order (1-2000) in the flow properties. How that fits into the processing of a record is covered in the Salesforce Order of Execution.

5. Document your Flow

Add a description to your Flow and use the description field on important elements. This helps colleagues (and your future self) understand what the Flow does.

Flow description: "This Flow runs when an Opportunity is won. It updates the related Account and sends a notification to the Account owner."

6. Watch governor limits

Salesforce has limits on the number of actions a Flow may execute. Avoid actions inside loops and use bulkified updates where possible.

  • Bad: Loop through 100 Contacts and update each Contact separately (100 updates)
  • Good: Loop through 100 Contacts, collect them in a collection, and update the entire collection at once (1 update)

Common automation scenarios

Here are some practical examples of when Flow provides a solution:

  • Lead assignment. Automatically assign new Leads to the right salesperson based on region, product type, or lead source.
  • Case escalation. When a Case in Service Cloud has been open too long, automatically escalate to a manager and update the priority.
  • Contract renewal. When a Contract is about to expire, automatically create a task for the account manager to reach out.
  • Opportunity approval. For large deals, automatically start an approval process where a manager must give approval.
  • Data synchronization. When a field on Account changes, automatically update the same field on all related Contacts.
  • Onboarding process. For a new customer, automatically create a checklist with tasks for different departments.

Conclusion

Salesforce Flow is a powerful tool for automating manual processes and making your team work more efficiently. By smartly automating processes you save time, reduce errors, and ensure consistency in your workflow.

Start small with simple automations, like sending a notification or updating a field. As you gain more experience, you can build more complex processes with loops, decisions, and subflows.

More about the objects your flows run on is in Standard and custom objects in Salesforce. All articles are in the knowledge base.

Want to clean up or expand your Flow landscape?

We design scalable Flows, set up governance and determine together where Apex or integrations are needed.

Schedule a Flow session