10+ Best Practices for Salesforce Flow

In this blog, we will explore best practices for Salesforce Flow that will help you create Flow solutions that are efficient & scalable.

As Workflow and Process Builders approach retirement, Salesforce Flow is poised to be the only automation tool within the Salesforce ecosystem.

Acquiring a deep understanding of the best practices for Salesforce Flow, designing and implementing them is crucial irrespective of whether you are an administrator, developer, or a business user.

10+ Best Practices for Salesforce Flow

1. Plan before building the Flows

best practices for salesforce flows Plan

Prior to starting the Flow development, it is crucial to allocate ample time for planning and designing your Flow solution.

Gain a deep understanding of the business requirements, process flows, and user needs to ensure a comprehensive and effective solution.

If you are in a dilemma, seek suggestions from the senior developers or stakeholders to ensure you are on the right path and avoid rework.

Consider the following things before developing a Flow:

  • Break down complex processes into smaller manageable flows to make them simple for future scalability.
  • Gather feedback from stakeholders and iterate on the design to ensure a seamless user experience.

2. Utilizing Entry Criteria

Flow entry condition

Entry criteria refer to a condition that should be met for the Flow to be executed.

Defining entry criteria ensures that the Flow is solely executed when the specified conditions are met decreasing the number of Flow interviews.

3. Add a description to your Flow elements

Also always add a description to your Flow elements as it provides clear understanding to the team members involved in the project.

Description on a Flow

Furthermore, descriptions act as a reference for training new team members, enabling them to quickly grasp Flow’s logic & contribute effectively to the project.

Want to Learn Salesforce Flows? Learn with our Salesforce Flow Course

4. Leverage Record-triggered Flows

Utilize the ‘Before-Save’ record-triggered flow to perform data manipulation or validation before saving the record.

It is suggested to create only one record-triggered Flow per object.

5. Avoid DML statements inside Loop

To avoid encountering SOQL limit exception errors, it is advised to avoid performing repetitive operations within a loop.

This approach ensures efficient processing and mitigates the risk of hitting governor limits.

6. Avoid hard coding values

By avoiding hard coding, developers can easily adapt and modify Flows to meet evolving business requirements without the need for extensive rework.

For example, Salesforce record Ids and URLs are dynamic and vary between different Salesforce org. It is better to use custom metadata or custom labels to store these values.

7. Use Subflows

Subflow are reusable Flows that can be called from other Flows, allowing you to break down complex processes into smaller, more manageable steps.

Subflow element refers to another Flow and invokes it at runtime.

To learn more about sub low click here

8. Error Handling and Exception Management

Ensuring the implementation of robust error handling and exception management mechanisms is essential to uphold data integrity and deliver a seamless user experience.

A fault connector is a type of connector used in Salesforce flows that allows you to handle errors and exceptions that may occur during the flow’s execution.

Fault Connector from Create record element to screen element

It allows you to take action in response to different types of errors, such as sending an email notification or displaying an error message to the user.

 

{!$Flow.FaultMessage} variable is used to show an error message on a screen component. Notify users or administrators about any encountered errors through email notifications or chatter posts.

Advantages of using Fault Connector:

  1. Better error handling
  2. Improved user experience
  3. Customizable error notifications
  4. Better flow performances

To learn more about error handling in Salesforce Flow, click here

9. Test the Flow

Flow builder is a user interface used for building Flows in Salesforce. It also provides us with a feature for testing the Flow before deploying it.

Make sure you test your Flow in developer org before moving it to higher sandbox org.

Always test the Flow using multiple records to handle bulkification.

10. Optimize Flow performance

Implementing Flows requires a keen focus on efficiency & performance, as they are pivotal aspects that significantly impact the overall effectiveness of your solution.

Follow these best practices to optimize the performance of your Flows:

  • Reduce complexity and improve runtime by minimizing the number of elements and conditions within your Flow.
  • Avoid hitting governor limits by limiting the number of queries and DML operations performed within the Flow.
  • Process multiple records simultaneously and reduce the number of elements needed by leveraging collection variables.
  • Perform calculations and manipulate data within the Flow without unnecessary assignments by utilizing formula resources and formula functions.

11. Avoid hitting Flow transaction limits

A flow interview refers to a particular execution of a flow, representing a complete run of that flow.

A transition in a Flow occurs when it progresses from one element to another for example from a screen element to a create record element.

To ensure effective execution, Salesforce imposes certain transition limits in a Flow.

Limitations per Salesforce Flow transaction:

  • 12 duplicate updates are allowed in one batch.
  • 10,000 records can only be processed as a result of DML statements.
  • 10 seconds is the maximum CPU time your servers can take to process your Flow solution.
  • Total number of SOQL queries issued – 100
  • Total number of DML statements issued – 150
  • Total number of records retrieved by SOQL queries – 50,000
  • Starting from API version 57.0, the limitation of 2000 flow elements per Flow interview has been eliminated. However, in API version 56.0 and earlier Flows were restricted to a maximum of 2000 flow elements.

12. NEVER build the Flow in Production

Creating the Flow in the developer sandbox allows developers to experiment and validate their solutions without impacting the live production data.

Before deploying to the production org, changes undergo testing and quality assurance processes.

This ensures that any errors or issues can be identified & resolved before deploying to the production org.

13. Knowing when to create a Flow

It is not mandatory to create Flow for each business requirement.

Consider multiple parameters in the future will it be more convenient to maintain or scale the given requirement in Apex code or Flow?

Get a complete Roadmap To Learn Salesforce Admin And Development 👇

Share Now

Harshit is a 5x certified Salesforce developer currently working at UST. He is a storyteller at heart, with a knack for crafting compelling content on LinkedIn and penning insightful blogs on Salesforce technology.

Similar Posts

One thought on “10+ Best Practices for Salesforce Flow

  1. I’d add: Improve the performance of Record Triggered Flows by taking advantage of the Fast Field Updates feature:
    If you need to update the same record that triggered the flow, use this functionality AND avoid using the Updates element, instead of that, use the ASSIGNMENT element with the $record variable.
    By doing this, Salesforce will not trigger another instance of flow since it will not perform another access to the Database. (Remember that each access to the Database is high-cost in terms of time and performance)
    Again, with Fast Field Updates (when flow runs before the record is saved to the database) there’s no need to use the UPDATE element when updating THE SAME RECORD that triggered the flow, just use the ASSIGN element with the $record, like $record.my_field__c = “new value”.

Leave a Reply

Your email address will not be published. Required fields are marked *