Mytutorialrack

Salesforce flows

Overview

Salesforce Flows, or simply Flows, help automate complicated business processes and manual data entry. They enable you to work more efficiently by saving time for users and ensuring tasks are completed accurately.

As a Salesforce admin, flows are a powerful tool in your toolkit. When set up right, flows impress your Sales team, but if they’re not set up well, they can be hard to manage or cause problems (similar to a rockstar’s unpredictable behavior).

This post  will cover everything you need to know about flows. Let’s get started!

What is a flow in Salesforce?

In Salesforce, a flow is a tool that automates complicated business tasks. In simple terms, it gathers data and then takes action based on that data.

Flow Builder is the visual tool used to create flows. It lets you build logic similar to coding, but without needing to use a programming language.

Flows fall into six categories:

Screen Flows

These flows include a user interface where users input information. They can be launched as actions or embedded as parts of a Lightning page.

Schedule-Triggered Flows

These autolaunched flows start automatically at scheduled times and run in the background, processing each record in a batch.

Autolaunched Flows

Use this flow type for automated tasks. Autolaunched flows can be triggered from other flows (subflows), Apex classes, scheduled times, record changes, or platform events.

Record-Triggered Flows

These autolaunched flows run in the background either before or after a record is saved, when a record is created, updated, or deleted.

Platform Event-Triggered Flows

These autolaunched flows run in the background when a platform event message is received.

Record-Triggered Orchestration Flows

Orchestrations enable you to create a multi-step or multi-user process when a record is created or updated.

Take a look at this example of a screen flow that manages employee recognition!

When/why should I use a flow?

Flow has become your all-in-one solution for customizable automation in Salesforce. If you need to create a new automated business process or a user-guided experience that doesn’t require complex Apex code, Flow is the tool for you.

Flow has become your go-to tool for customizable automation in Salesforce. Whether you need to create a new automated business process or a user-guided experience without dealing with complex Apex code, Flow is the solution for you.

Flows can create, edit, and delete records in Salesforce, send emails, display relevant data to users, collect input from them, and generate outbound messages.

When should I not use a flow?

Generally, you should avoid using a flow in the following situations:

  • You lack a clear understanding of the business process you want to automate.
  • If there is complex logic that is better handled with Apex code, such as logic that makes debugging difficult or managing the flow challenging, Apex might be the better solution. Developers can create invocable Apex methods that flows can call (similar to calling a subflow). This allows you to delegate especially complex processes to Apex while still using Flow Builder to manage the overall process. Flow continues to evolve, and with new features like collection filtering and sorting, there are fewer specific cases where Apex code is necessary.
  • If your Salesforce edition restricts the number of flows you can create. Essentials and Professional editions have limits on processes and flows per organization. For simpler logic in these editions, using a process may be more straightforward.

How do I create a flow in Salesforce?

To open Flow Builder, go to Setup, type “Flows” into the Quick Find box, select Flows, and click New Flow. Choose the Flow Type, then click Create.

The type of flow you create affects how you work with it. Scheduled and record-triggered flows automatically provide a global variable called $Record. This gives you access to all fields on the triggered record (and its parent records!). For autolaunched flows, you need to create any needed input variables yourself.

After setting up your inputs, click the + button next to the start element. You’ll see a list of elements that perform different actions for your business processes. Each element can execute actions such as reading or writing Salesforce data, showing information to users, gathering data from them, running business logic, or managing data.

Save your flow.

After building a flow, thoroughly test it to ensure it works correctly. Once tested, activate the flow. Now you can distribute it to users.

Pro tip:Flows can be triggered in various ways, depending on their intended users or systems. They can be run by internal users, external users, or other organizations. No matter how you execute it, remember to go with the flow!

Another pro tip: Flows offer two layout modes. Auto layout is designed for new flow builders and accessibility tools like screen readers, making it highly accessible. It’s recommended for its standardization and readability. However, if you need to make extensive changes to the flow, especially rearranging elements, you may switch to free-form mode.

For more detailed examples on building flows and other Salesforce insider tutorials, subscribe to our newsletter for monthly updates and knowledge-sharing!

Flows vs. Apex

Apex code needs a developer and Sandbox for deployment, so it’s typically used in Salesforce editions like Professional and above. Flows, on the other hand, can be built in all editions. Although a Sandbox isn’t necessary to move a flow to production, it’s advisable—especially for complex flows—to build and test in a Sandbox before deploying them live.

In Salesforce Essentials, Apex is not available, and some Apex features are limited in Professional edition. However, organizations with Enterprise and above editions have no Apex limitations. In contrast, flow features are not restricted by edition. Additionally, maintaining Apex code requires ongoing development and discipline, while flows are easier to keep updated.

Flows can be built by admins, whereas Apex code is usually developed by a developer. For straightforward business logic, Flow is generally preferred over Apex code. However, Apex is crucial for solving complex problems and maintaining precise control over automation in enterprise environments. Flows are simpler and should be prioritized over Apex code when possible.

If the logic becomes too complex, Apex code is the appropriate choice. Each Salesforce release introduces new features that decrease the need for Apex, but there are still scenarios where Apex can provide performance advantages and should be chosen over Flow. Tasks like renewal generation and managing Opportunity Products, traditionally handled with Apex code, can now be implemented using flows, which reserves Apex capacity for projects demanding its capabilities.

Apex code should be used in the following scenarios:

·  Your flow requires nested loops that can’t be handled with the new filter or sort collection actions available since Spring ’22.

·  There’s already a trigger framework in place for an object.

·  Your flow needs to use Get elements within a loop.

·  You’re dealing with very large amounts of data.

·  You require custom integrations with other systems that involve more than a basic callout to an external service.

Flow: the Automation Tool of the Future

Admins can no longer create new Workflow rules and Process Builders. All new automation should be developed using Flow, and there should be strong consideration given to migrating existing workflows and processes. This transition is becoming more critical, especially since Salesforce has announced the end of support for Process Builder and Workflow rules by December 2025.

Considerations for Migrating to Flow

Whether you have a few simple processes/rules or a complex web of automation built over many years, if you’re migrating from Workflow or Process Builder to Flow, start by documenting your existing automation and setting up a Sandbox. Salesforce offers a migration tool to help you get started, and there are also third-party tools available for migration.

Migration tools can automate much of the tedious work, but their use requires caution. When migrating to Flow, take the opportunity to evaluate the following:

·  Do we still need the existing automation?

·  Are there pain points in current solutions that Flow’s better tooling can resolve?

·  How few record-triggered flows are necessary to meet our needs?

·  Can recurring small business logic be consolidated into subflows?

Once you and your team of end-user testers have confirmed that the migration is ready for production, follow these steps:

  1. Timeline and Communication Plan: Create a timeline and plan for communicating the deployment to stakeholders and users.
  2. Activation and Deactivation: Activate your new flows and deactivate any workflows or processes they replace.
  3. Deployment Strategies for Large Orgs:
    • Phased Deployment: Roll out the new flows in phases across different departments or functions.
    • Parallel Run: Run both old and new automation in parallel for a period to ensure smooth transition.
    • Big Bang: Implement all changes at once across the organization, ensuring comprehensive testing beforehand.

These strategies help manage the transition effectively, minimizing disruptions and ensuring the success of your Flow deployment.

When handling processes and workflow rules during migration, consider these strategies:

  • Utilize a custom setting to disable all processes simultaneously.
  • Plan migration during low system usage or schedule an edit moratorium.
  • Employ a deployment or migration tool to set processes and workflow rules to “Inactive.”
  • Ensure flows are covered by unit tests or Apex tests to enable deployment as “Active.”

These steps help streamline the migration process while maintaining operational stability and readiness for deployment.

Migration can be a significant project with many dependencies. Consider partnering with an implementation partner experienced in designing scalable automation, such as Kicksaw, to help manage the complexity effectively.

Debugging Flows

To ensure your flow works correctly, click the Debug button on the canvas, input your variables, and click Run. Go through the flow to verify that it functions properly. This process is particularly useful for screen flows.

Note that starting from the Winter ’21 Salesforce release, there’s a beta feature called Debug on Canvas. This feature simplifies flow debugging by visually showing the flow’s path when it runs. It also displays query limits in the debug details. Moreover, debugging now includes two new options: running the flow as another user and running the flow in rollback mode.

Use Flow Tests to Automate Your Tests

Record-triggered flows allow you to configure flow tests for automating your testing process. With flow tests, you can set up an initial record, change its values, and simulate its journey through your flow. After running the flow test, you can set assertions to confirm that the expected outcomes were achieved.

For those unfamiliar with unit tests, here’s a simple example: Imagine you have a record-triggered flow on an Opportunity that updates the Account’s Type to ‘Customer – Direct’ when the Opportunity’s stage changes to ‘Closed Won.’ To test this, you can select a test record and manually update its stage to a non-‘Closed Won’ stage using the interface. This helps simulate different scenarios and verify how the flow behaves in each case.

Next, configure the test record to be marked as ‘Closed Won’ so that the flow triggers. The flow test will simulate this record update. In our example, we would set up an assertion to verify that the Account’s Type has changed to ‘Customer – Direct’ after the flow runs. This helps ensure that the flow behaves correctly according to the defined logic.

During the flow test, we simulate the record update. In our example, we would set up an assertion to confirm that the Account Type has been changed to ‘Customer – Direct.’ This verifies that the flow is functioning correctly as per the defined logic.

Considerations for Flow Tests

·  in the interface, you can’t update related records directly. Flows that depend on specific conditions across multiple objects may fail if related data changes.

·  Use the ‘Equals’ operator for assertions, as the tool restricts referencing flow variables with the ‘Does Not Equal’ operator.

·  For very complex tests, think about using Apex tests.

·  While subflows (autolaunched) aren’t directly supported, they can be tested if referenced by a record-triggered flow.

Where is the Flow Builder in Salesforce?

To find the Flow Builder in Salesforce (Lightning), navigate to Setup > Process Tools > Flows.

What are the different Flow Types in Salesforce?

Auto-Launched Flows with No Flow Trigger

These flows do not involve user interaction and do not support screens, local actions, choices, or choice sets. The available distribution methods include:

  • Flow actions
  • Lightning pages
  • Lightning community pages
  • Custom Aura components
  • Custom Lightning web components
  • Custom buttons or custom links
  • Web tabs
  • Direct flow URLs
  • Visualforce pages
  • Lightning out
  • Embedded service deployments

Auto-Launched Flows with a Schedule Trigger

These flows operate solely based on a schedule set by the user. They do not support user interaction, screens, local actions, choices, or choice sets. The available distribution methods include:

  • Processes
  • Custom Apex classes
  • REST API
  • Web tabs
  • Custom buttons or custom links
  • Visualforce pages

Screen Flows

Screen flows involve user interaction as they include screens, local actions, steps, choices, or dynamic choices. They allow you to customize the user experience for guided processes. Here are some screen flow options along with a typical use case:

  • Screens: Display information or gather input from users.
  • Local Actions: Perform actions within the flow without server interaction.
  • Steps: Sequence of actions or decisions.
  • Choices: Provide users with options to select from.
  • Dynamic Choices: Offer dynamically generated options based on data or conditions.

Common Use Case:

  • Employee Onboarding: Use screens to collect new hire information, offer choices for department selection, and include local actions to update employee records.

These components enable flexible and interactive workflows tailored to user needs in screen flows.

Here are explanations for various components used in screen flows:

  • Display Text: Provides formatted instructions tailored to your business process.
  • Input Components: Include text fields, checkboxes, dropdowns, picklists, and date selectors to gather various types of information from users, aligned with Salesforce custom field data types (excluding time).
  • Data Table: Dynamically lists available products related to a specific opportunity type.
  • Display Image: Enhances the user interface by displaying a branded logo or other images.
  • Lookup: Enables selection of a record that can be modified or used as a parent record.
  • Slider: Allows users to provide ratings like CSAT or NPS using a sliding interface.
  • Toggle: Improves user interface by using a toggle switch instead of a checkbox to determine the next screen in the business process.
  • Repeater: Lets users add multiple child records to an object and iteratively input data for each.

These components enhance user interaction and customization within screen flows, tailored to different aspects of business processes.

Autolaunched Flows with a Record Trigger

These types of flows are tailored to efficiently enact straightforward modifications to a record upon its creation, update, or deletion. They can be set up to execute these changes either before or after the record is saved to the database:

  • Before-Save Flow: Supports elements such as Assignment, Decision, Get Records, and Loop. Executes changes before the record is saved, offering basic automation capabilities.
  • After-Save Flow: Accesses all flow capabilities. Executes changes after the record has been saved, providing more extensive automation options and flexibility.

Record-triggered flows are powerful but can also be a source of frustration. If there’s an unhandled error in your flow, it can prevent users from saving information. This issue is particularly critical when the flow is triggered by an integration update. To prevent potential data loss, it’s best practice to execute these flows asynchronously. This approach ensures that the save operation can proceed even if there’s an unhandled error in the flow.

Autolaunched Flows with a Platform Event Trigger

Platform events serve to link Salesforce business processes and external applications by facilitating real-time event data exchange. Historically managed by developers, platform event-triggered flows empower users to leverage flow capabilities for handling integration data efficiently.

One potential use case involves handling SMS events. Suppose you’re using an external provider to send SMS messages to your contacts and want to synchronize these messages with Salesforce. In this scenario, you can configure a Platform event to store details such as message content, contact name, phone number, and optionally, the contact or lead ID from the external system. When an SMS message event occurs, your provider can generate a platform event. In Salesforce, you can then create a record for this message if the lead or contact already exists. Additionally, if no matching lead or contact is found by name or phone number, you can create a new lead or contact record dynamically.

Record-Triggered Orchestration Flows

Record-triggered orchestration flows enable you to assign a set of processes to a user or group of users based on actions taken on a record. When triggered, these orchestrations display a custom screen element on the record assigned to the user. Once the user completes their assigned tasks, the orchestration progresses to the next step automatically.

An excellent use case for an orchestration flow is when an opportunity transitions to “Closed Won.” Beyond securing signatures, this phase is crucial for delivering outstanding service to your new customer. With orchestration, you can automate tasks such as assigning a project spin-up to your Customer Success team, handling invoicing tasks for your Finance team, and scheduling a follow-up thank-you activity for your Sales representative. This ensures a coordinated and efficient process for customer onboarding and satisfaction.

What is a flow interview in Salesforce?

While a flow is an application created by your administrator that prompts you for inputs and performs actions in Salesforce based on those inputs, a flow interview is an active instance of a flow currently running and interacting with users or data.

For instance, a flow might generate a call script for customer support calls based on the information you provide when creating a case. How the flow processes the information you enter is entirely determined by your administrator’s configuration.

When you initiate a flow interview, whether through a link, button, or tab, you’re launching a single occurrence of a flow. To clarify, think of the distinction between a record and an object. For instance, you create an account record, which represents a specific instance of the account object that your administrator has tailored.

Monitoring the Paused and Failed Flow Interviews lists in Setup > Paused and Failed Flow Interviews is highly recommended. These lists are invaluable tools for flow management. The Paused Flow Interviews list allows you to review flows that include time-based actions or screen flows that users have not finished. However, the Failed Flow Interviews list is particularly beneficial because it highlights flow errors and provides access to the debug log for each flow interview. This makes it the primary resource for troubleshooting flow-related issues.

Read more about flow interviews in Salesforce’s documentation.

Showing A Screen Flow to Your Users

Using a Quick Action

Screen flows or Field Service Mobile flows can be initiated from a Quick Action button, allowing you to tailor a business process according to a particular record in Salesforce.

To create a custom action for a record in Salesforce using Flow, follow these steps:

  1. Navigate to Object Manager:
    • Go to Setup by clicking on your profile avatar and selecting “Setup” or by appending /setup/home to your Salesforce instance URL.
    • In Setup, enter “Object Manager” in the Quick Find box and select it.
    • Click on the object name (e.g., Account, Opportunity) for which you want to create the custom action.
  2. Create the Custom Action:
    • In the Object Manager for your chosen object, click on “Buttons, Actions and Links” in the left sidebar.
    • Click on the “New Action” button.
    • Select “Flow” as the action type.
  3. Configure the Custom Action:
    • Name your custom action.
    • Select the Flow that you want to use for this action from the dropdown list.
    • Optionally, you can specify input variables. If you want to automatically populate the {!recordId} variable with the current record’s ID, create a text or record variable named recordId in your flow and mark it for input.
  4. Add to Page Layout:
    • After saving the custom action, go to the page layout(s) where you want to add this action.
    • Edit the page layout and drag the custom action from the Mobile & Lightning Actions section to the Salesforce Mobile and Lightning Experience Actions section.
    • Save the page layout.
  5. Testing:
    • Navigate to a record detail page of the object you configured.
    • Look for your custom action button in the Salesforce Mobile and Lightning Experience Actions section.
    • Click on the button to run the associated Flow. The {!recordId} variable will automatically be populated with the ID of the record you are on when clicking the button.

By following these steps, you can create and use a custom action in Salesforce that triggers a Flow, with the ability to pass the current record’s ID to the Flow automatically.

On a Lightning Page

You can put Screen Flows on a Lightning page for your homepage or for a specific record. When you add a flow to the page, you can fill in details about the record you’re looking at. This means the flow can use information from the record, like its ID or other data, if it’s on a record page.

If you have a Lightning record page that includes a flow on the main tab, the flow starts running as soon as your user opens the page. If the flow requires a lot of resources, it could slow down the page loading time. To speed things up, you might want to put the flow on a different tab that isn’t visible right away when the page loads. This way, it won’t start running until your user actually switches to that tab.

In a Digital Experience Site

Just like you can add screen flows to Lightning record pages, you can also add them to your Digital Experience site by placing them on site pages and setting up the right input details. It’s important to ensure that users of your Digital Experience site, including guest users, have the necessary permissions. This ensures they can access and interact with the records that the flow uses. They also need permission to run the flow smoothly.

Common Mistakes Made When Designing Flows

Here are some common mistakes we’ve noticed that you can easily avoid:

  • Using the wrong field or variable.
  • Forgetting to check for empty values.
  • Putting Get, Create, Update, or Delete actions inside a loop.
  • Referring to objects or fields that users might not have permission to access.
  • Deploying flows without testing them with the actual users who will use them.
  • Not granting users access to run flows.
  • Using Get actions unnecessarily when data is already available through $Record or $RecordPrior in record or scheduled trigger flows.
  • Hardcoding record IDs instead of using dynamic references.

We hope you’ve gained a better understanding of the capabilities of Salesforce flows from this article. If you need additional assistance, please refer to the official documentation.

For further learning, we recommend completing the “Salesforce Lightning Flows Course” on Mytutorialrack. This interactive course will provide you with hands-on experience and insights into Flow Builder.

Keep exploring and reading more about Flow Builder to enhance your Salesforce skills.

Share:

Recent Posts