When building automation, whether that’s flows or apex, you’ll eventually find yourself building business logic.

Business logic is basically a module that performs a certain function in response to a business need. For example, a screen flow that creates contacts may want to first verify whether an existing matching contact exists before creating a new one.

So the flow can perform one or more get operations, using different criteria such as first name, last name, email address, and so on.

The portion of the flow that manages this verification is called business logic.

And whenever creating business logic, it’s a good idea to keep a modular architecture in mind. This means placing the logic into a subflow or invocable apex method, so that it can be used in multiple circumstances.

Keep in mind that if it’s the first and only use of business logic, then it’s OK to not place it into a subflow. But the moment this logic is used in a second instance, then moving to a modular architecture is highly recommended?

Why? Because you don’t want to ever have to update business logic twice. If the contact verification process changes, it should be changed in one and only one location.

The takeaway
It’s a good idea to create reusable business logic using subflows or invocable apex methods.

Category:
Salesforce