Salesforce Flow Best Practices

Never Perform DML Statements in Loops

Never ever perform a DML Statement inside of a Loop. This means don’t use a repetitive Get/Update/Create, or Delete inside of a Loop. This is so that your risk of hitting a governor limit is significantly reduced as you’re able to control the number of times one of these data elements is used. If you need to loop through and update multiple records, always remember to assign a collection variable and perform your DML Statement outside of the Loop.

One Record-Triggered Flow Per Object

Its better to create one record triggered flow per object so governor limit can be avoided, So for any new flow requirement first check the existing flow for that object and then do your new changes inside the existing flow.

Build Reusable Flow – Subflow

Create the subflow for any repetitive task that can be used by any other flow. A subflow is an autolaunched flow (no trigger) or a screen flow, which is referenced by another flow (called the parent flow) and calls the subflow at its runtime. Use the subflow’s input and output assignments to pass data between the parent flow and the subflow.

Take advantage of clean, concise, and more organised flows by using subflows.

Maintain documentation for flows

As Flow will be viewed/maintained by other Salesforce Developer/Administrators. You should always create supporting documentation to make it easier for them to understand what your Flow does and the key elements and functions that it performs to make their job of maintaining the org easier.

Avoid Hard coding IDs

Flow does not yet let you reference the Developer Name of things like Record Type, Queues, or Public Groups in certain parts of the UI, but that doesn’t mean you should be hard coding the ID. Use a formula for your entry conditions will let you reference a Record Type’s DeveloperName in your triggering conditions.

Handle Faults

Faults or errors may occur while working with flows so you should handle them properly. Make sure your users are presented with detailed error messages when unexpected actions occur.

 

Share your love:

Leave a Reply

Your email address will not be published. Required fields are marked *