Salesforce Flow Best Practices
Plan Plan and Plan
If you don't take anything else from here, trust me on this one, especially if you are a flow beginner. This part is so important and overlooked most of the time. I get it, we want to start building right away because it's fun and sometimes it might feel like a waste of time! But wouldn't you want to start on the right foot? Just get the basic requirements and draw that out on a piece of paper. It can be iterated upon based on feedback, which is the beauty of flows! Remember it doesn't have to be perfect.
Some tools/tips on planning:
- Use whiteboard, online or in-person
- Use miro, mindmaps, lucid-chart, or any visualization tool of your choice
- Or just your notebook or scratchpad
Honestly, we have all done it. Test1, test2, FlowTest, etc especially when you are new and are not really worried about naming it right, you are trying to ‘get it to work’ and once it works, you don't want to touch it.
Bad naming conventions will definitely haunt you later and cause too many problems which can be avoided by simply taking a few seconds to name.
Most common places you can start to name them correctly:
- Flow itself — eg: Account After Insert Flow, or Call Center Welcome Screen Flow, there are no rules but keep it consistent
- Flow variables — you can use camelCasing here. eg: oppList, or opportunityList, accVar, firstName, etc
- Elements like Screen or Get Record or Update — also camelCasing starting with a verb. eg: getAccountList, createOppty, capturePatientInfo, etc
- Formula — eg: dateToday, constTerm, etc
Flow per object — Record triggered flows
- How many flows per object: If you have complex requirements, you may end up having multiple flows on the same object, in different contexts Before/After Insert/Update, Delete. This is no issue in terms of performance besides, there is still no way as opposed to triggers to add them under one flow. Make sure you are very conscious of what is happening in all the other flows, especially if they are in the same context. If you have 2 flows both firing on Before Insert and the same condition, this can be an issue and you want to combine them. If you have 2 Before Insert flows but completely different entry criteria, it’s not a bad design and doesn't hurt performance. In fact, sometimes it’s best to keep it separate when you have different stakeholders and requirements so you are not impacting a different flow.
- Use Criteria in your Flows: You need to always be asking this question to the business on when do you want to fire this. In flows, you can use criteria either directly on the start node or on decision nodes to go through different paths based on the outcome of a decision. Or a combination of both.
- Check what other automation are present on that object like triggers, w workflows, processes.
Read on Order of Operation
Insert/Update/Delete inside a For loop
This is mostly an issue I notice from admins which is totally understandable because it's also an Apex concept where using DML inside a flow loop is forbidden. You might not notice any significant impact immediately or never if you will only ever update very few records at once. But once your org gets complex or you need to update potentially over 100 children records inside a loop, you will start seeing errors.
- Make use of the Assignment element to assign values to a collection inside the loop instead of Insert or Update- shameless plug watch my video here
- Be conscious that every database interaction you make counts towards the limits
Have Fun and play with flows, that's the best way to learn Flows! Do not be initimidated and rech out for help. There are tons of resources out there and folks ready to help you!
Note: Every org is different so you will have to play around and decide which one works best for you. Hopefully these gave you good pointers but definitely not an exahustive list.
My beginner Flow Playlist if you don't already know my channel.
Same topic in a video.
Please join the conversation here or comment with your thoughts! I will be sharing more so please follow if you like this.