What are Flow Best Practices in 2023?

There are some best practices that you must follow while working on flow. They are:

Plan your Flow Before you Start Building

Write or draw all the details of your business process. Then it will be clear what information you need, where to get that information, and what logic and actions to take. This makes it easy to create the right flow. 

Build Your Flow in a Test Environment Such as a Sandbox or Developer Edition Org

You do not want to accidentally change records in your company's production org. Build your flow in another environment. This allows you to enter fake data and test different permutations of your flow without worrying about changing or deleting data that your users actually need. 

Never Hard-code Salesforce Ids

IDs are specific to your organization, so don't hardcode new or existing IDs. Instead, Salesforce creates IDs and passes them to variables when the flow starts. For example, you can use merge fields in the URL parameters or use the Get Records element to do this. 

Wait for the Flow to Complete to Make Changes to the Database

Have you heard of flow limits? The sky is not the limit because flows operate below the apex governor boundary. To avoid hitting these limits, we recommend aggregating all database changes at the end of the flow, regardless of whether the changes create, update, or delete records. Also, avoid changes in loop paths. 

dont miss out iconDon't forget to check out: What are Flows In Salesforce in 2023?

Control When Running Users Can Navigate Backward

If the flow commits changes to the database or performs actions between two screens, prevent the user from navigating from later screens to earlier screens. Otherwise, the flow may make duplicate changes to the database. 

Provide an Error Handler

Unfortunately, sometimes a flow doesn't execute the operations you've configured. The flow may be missing important information, or the active user may not have the required permissions. By default, the flow will display an error message to the user and send an email to the admin who created the flow. However, you can control this behavior. For more information and recommendations, see Customize what happens when a flow fails. 

Save Early and Often

Flow Builder can fall victim to unexpected issues such as loss of internet access. Salesforce doesn't automatically save your changes, so it's up to you to save your work. Save as often as possible to avoid accidentally wasting hours of work. 

Restrict Data Access Through Profiles and Permission Sets 

Ensure that only the right flow users have access to data at the right time. To restrict access to active profiles or permission sets, edit the flow's access in the flows list view. 

dont miss out iconCheck out another amazing blog by Nikhil here: What are List Views in Salesforce?

Control Data Access with the Subflow Element

If your flow should respect user permissions for some actions and ignore user permissions for others, you can use the subflow element. To respect user permissions on actions, create flows that run in the user context. To ignore user permissions such as object permissions or field-level access for other actions, create another flow that runs in the system context. In summary, a flow running in a user context can use a subflow element to initiate a flow running in the system context. 

Test as Many Permutations of the Flow as Possible

As with all Salesforce customizations, it's important to test your work. This is especially true if the flow uses branching or other complex logic. Test as many possibilities as possible before distributing your flow to your users. 

Avoid Accessing External Objects after Performing Dml Operations in a Transaction 

An error occurs when Salesforce creates, updates, or deletes data in your org and then accesses external data in the same transaction. We recommend that you use separate transactions in your flows to access data from external systems. To do this, add a Screen or Local Action to your Screenflow, or add a Pause element to your Auto launched flow to complete the previous transaction. If you use the Pause element, don't use the record-based resume time.

For example, a screen flow creates a contact and displays a confirmation screen. The flow then updates the contacts in the external system. The flow doesn't fail because it uses another transaction to access the external data.

Responses

Popular Salesforce Blogs