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?
- 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?
Be careful with null and unassigned values.
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!