skip to Main Content

Using Flows in Salesforce

Using Flows In Salesforce

Follow along as we share best practices for Salesforce automation.

We recently kicked off our new series on choosing the right Salesforce automation. Today, we go deeper into the third real-time automation option to consider: Flows!

When Should I Use Flows in Salesforce?

After you’ve eliminated workflow rules and process builders as automation choices, consider using flows. Flows perform many functions that process builders cannot, and are the best option in the following scenarios:

  • When you need to do a query

  • When you need to create records and reference the results in a subsequent update

  • To do a screen flow — screen for user to interact with

  • To launch an action from a button

  • When you need to create multiple or dependent objects/records  (for example, when you need to create a record from the account, like clicking a button to create an opportunity and/or product)

  • To delete records

What Do I Need to Know When Using Flows?

No matter what type of automation you choose, understand that with great power comes great responsibility. Salesforce’s no-code tools seem simple, but are incredibly powerful, and if they’re not handled correctly they can cause major issues for your org. Here are a few key things to watch out for when using flows.

Be careful with null and unassigned values.

If you’ve ever received an error that says “variable has not been set or assigned,” it means that your flow is attempting an action based on an empty or unassigned value. For example, if you’re performing automation on a contact based on an account field, your flow will fail if the contact is not associated with an account. To prevent this, always use decision elements to ensure a record was found or a variable is populated.

Think about data volume.

As a flow can be triggered simultaneously on multiple records, you need to carefully think through data volume possibilities in your flow. For example, if you are creating a renewal opportunity with associated products, it can amount to a very high volume of data, causing a CPU timeout error. As a safeguard, schedule the flow with controls on batch size, or invoke the flow using batch Apex.

Make sure your field types match up.

A common mistake with flows is setting a screen component field type that does not match the field data type. Mismatched field types—for example, trying to put text into a number field—will inevitably cause failures in your flow. This is another case where admins need to think like developers and make an effort to understand the data relationships within the object model.

Beware of loops.

Putting an update or a query in a loop will cause a “too many SOQL queries: 101” error if your data volume is too high. As a general rule, avoid ever putting an update or query in a loop, and instead use lists.

Think logically through all possibilities.

When it comes to flows, a best practice is to always think very methodically through the logic of your steps. If you take the time to think through every possible route and decision your data may encounter in the flow, you will catch and eliminate many of the possible errors outlined above. For every part of your flow, ask yourself, “What will happen if X?” For example, what will happen if a user enters an unexpected value? What if a field is empty? What if a field is not required? And more.

In a nutshell: think like a developer, and you’ll avoid many common pitfalls.

What issues have you run into with flows? We’d love to hear from you!

Next up in the series, we’ll be discussing Apex triggers. Follow us on Twitter or LinkedIn for the latest.

Back To Top