Most good Salesforce consultants are already familiar with good flow practices. Things like
- Don’t create/update/delete records (DML operations) within loops
- Don’t do multiple gets of the same record or related records
- Don’t update the triggering record in an after-save flow
- Etc.
What some consultants may not be aware of is that Salesforce automagically bulkifies operations *across* flows.
For example, let’s say you have an record-triggered flow that checks to see if an account exists. If it doesn’t, it creates the account.
Each time the flow is triggered, Salesforce creates an instance of the flow. Now imagine the flow is triggered multiple times, around the same time. You may think each instance runs independently, but they don’t. They are bulkified.
This means Salesforce executes the first flow instance up to a certain point. Then it pauses to see if there are other instances that also need to run. If so, it executes those up to the same point.
This point is usually a DML operation, which allows the platform to perform a single DML operation across multiple flow instances. Then each flow instance continues.
Why is this important to know? To be continued tomorrow…
The takeaway
Bulkification doesn’t just happen within a single flow. It can automatically happen across multiple flows, and we have very little control over this.