Go to portal

What Goes Wrong With Poorly-Designed Salesforce Flows and How to Put it Right

The use cases for Flows are unlimited. As every Salesforce admin with no apex code knowledge can create and use flows, they are becoming very popular. However, if the flows are poorly-designed, they can become difficult to manage, create a mess in the organization, or even produce the loss of valuable data. At Quality Clouds, we work with clients to make Salesforce flows work hard for the business. Here’s how to create best practices for Salesforce flows.

 

How Do Salesforce Flows Work?

 

Flows are an automated tool provided by Salesforce that help you build complex business logic using clicks instead of code. Flows can collect, update, edit and create information, as well as execute logic, guide users through screens and even call Apex Classes.

 

Currently, Salesforce offers us 5 different types of Flows:

  • Screen Flow. With Screen Flow, you can create a custom user interface to guide users through a business process.
  • Scheduled-Triggered Flow. This flow launches at the specified time and frequency
  • Autolaunched Flow. It launches through Apex, a process or even a RES API
  • Record-Triggered Flow. This flow executes when a record is created, updated or deleted
  • Platform Event-Triggered Flow. This flow executes when a platform event message is received.

 

How to Avoid Poorly-Designed Flows

 

When flows are not well-designed they cause issues in the organisation’s system. Here’s how to stop that from happening and create some best practices for Salesforce flows:

 

  • Document your flows. The flow you are creating will be used by other users and probably will need to be changed in future, so the better the documentation is, the easier it will be to maintain
  • Check for nulls. You need to be ready for every scenario that could happen, and that means you are not sure about the data the flow is going to receive. Introducing a decision like, ‘Is null EQUALS False’ will avoid possible problems
  • Don’t hardcode IDs. Instead, use the results of a Get Element, a Custom Label or Custom Metadata
  • Be careful with executed element time. As of Spring ‘21 there are currently 2000 element executions allowed per flow. Always be aware of that, specially when introducing loops
  • Avoid DML inside loops. If you need to do complicated logic over a collection, we do recommend to use Apex
  • Don’t mix Triggers, Process Builders, workflow Rules and flows. It is better to choose one automation tool per object. If you mix strategies it could turn out in poor performance, or unexpected results, besides really hard maintaining

 

As an example, consider the following flow:

Salesforce flows graph

What Goes Wrong with Poor-Functioning Flows?

 

This flow executes every single time an Account is updated in the instance. It collects all the records related to the account that has been modified and perform some changes on them as well.

 

This is a very simple flow that any user could create easily, but it can raise a lot of problems in the organisation. Without getting into internal details, we can see a main issue here: the changes in the contracts are done within a loop. Therefore, if an Account with a lot of contracts is modified it will hit the DML limits, and it may end up failing.

 

How Can We Create Better Flows?

 

To sum up, flows are a very powerful tool, and offer great benefits to organisations. To stop them from being a disruptive element we should keep in mind these small tips and create best practices for Salesforce flows. This will help to avoid issues or unexpected behaviours and leave the organisation and the system’s users able to make use of Salesforce flows successfully.

 

We’re offering a free, 30-minute consultation on how Quality Clouds can work for your business. Drop us a line to set up a consultation.

x