Apex or Flow: What Is the Choice of the Salesforce Community?
While working on the series of articles about Apex and Flow and their tradeoffs I decided to make a survey and ask my Salesforce network on Linkedin which solution they would prefer, when starting a new project. Results were quite insightful, and I would like to share those with you below.
Table of contents
Flow or Apex: What Does LinkedIn Salesforce Community Say?
In July I conducted a poll on LinkedIn to understand preferences between Flow and Apex for the new Salesforce project:
Analyzing the responses and doing breakdowns by their roles, experience and skills, I came to 4 distinct conclusions:
Conclusion #1: No matter of Seniority of the Salesforce expert, all levels prefer Apex.
Conclusion #2: Certified Salesforce specialists give strong preference to Apex, while not certified have an equal 50/50 split of choices.
Conclusion #3: All surveyed respondents with main job titles Salesforce Consultant and Analyst voted for Flow as their preference, while Developers gave a strong preference to Apex.
Conclusion #4: If a respondent had Flow in LinkedIn skills mentioned, they are likely to vote for Flow, while if Apex is on skillset – then preference will be given to Apex.
And let me share more original insights from participants on the question “When selecting between Apex and Flow for a new project, which will you prefer?” below:
Paweł Kaca, Salesforce Developer
“Regarding the usage of Apex or Flows in new projects.
In my opinion, it depends on multiple factors:
- Complexity of object/logic
- Predicted number of records in the object
- Size of project/development team
For small projects, not complex logic sure flows will be a good solution, and for any other scenario, I would recommend using Apex and triggers.
The biggest no-go with flows for me is if, at any moment of future project development, there is a situation in which two people from the team need to work on the same flow/sub-flow. This is just not possible due to the lack of possibility of good versioning and flow metadata merging capabilities. Usually, merge conflict situations end with the scenario that one developer needs to replicate his job based on another developer’s flow version.”
Michał Wiszenko, Senior Salesforce Developer at Deloitte Digital | 12x Salesforce Certified
“Obviously the question is not easy to answer, because the choice will always be dictated by multiple criteria (budget, timeline, org size, skillset of the team, etc.), and the most likely scenario is to simply end up having a mixture of both solutions.
To answer your question, though, my main point is that one can implement a very complex full-code system, but it’s impossible to replicate that with a flow-only approach due to its limitations. On top of that, Apex provides more control over code execution, allowing major performance optimizations, which is one of the main keys to a scalable system. However, it’s obviously quite handy to also have flows as a quick, declarative way to configure more basic automations. In the end, in a real-life scenario, each tool will find its use, just for different reasons and purposes.”
Best Practices for Choosing Between Apex and Flow
Choosing between Apex and Flow for your Salesforce project is important, let’s sum up how to make the best decision based on the opinions and answers we’ve received.
How to Decide
Project Needs
- Simple Tasks: For straightforward tasks like sending emails or updating records, Flow is a great choice. It’s quick and easy to set up.
- Complex Tasks: For intricate processes requiring detailed logic and integrations, like Salesforce Netsuite integration or similar, Apex is better. It offers the flexibility and control you need for complex business rules.
Team Skills
- Non-Coders: If your team mainly consists of admins or business analysts who don’t code, Flow is ideal. Its visual interface makes creating and modifying processes simple.
- Coders: If you have skilled developers, using Apex can unlock advanced features and customization that Flow can’t provide.
Performance Needs
- High Performance: For tasks needing high performance, especially with large datasets, Apex is usually more efficient.
- Moderate Performance: For tasks that don’t require heavy processing, Flow’s ease of use and rapid deployment make it a good choice.
Maintenance
- Easy to Maintain: Consider long-term maintenance. Flows are easier to build but can become complex and hard to debug over time. Apex requires more effort initially but can be easier to maintain.
Recommendations Based on Needs and Skills
- Start Simple: Begin with Flow. It allows you to quickly set up automation and see results. Philippe Ozil advises, “A good rule is to first try to build something with low code (Flow) and if it’s not possible, move to code (Apex).”
- Performance Check: If you hit performance issues with Flow, consider switching to Apex, especially for tasks with large data volumes or complex calculations.
- Combine Tools: Use both tools together. For example, use Flow for user interactions and simple logic, and Apex for backend processing and integrations. This combination often provides the best balance of ease of use and performance.
- Train Your Team: Invest in training. If your team lacks coding skills, provide Apex training. Make sure non-developers are comfortable with Flow to maximize its benefits.
Future Trends and Developments
Staying updated on Salesforce trends helps you stay ahead. Here are some trends and predictions:
Better Automation Tools
Salesforce is enhancing Flow with new features, making it more powerful and flexible. Expect improvements that address some current limitations.
- It’s clear that Flow PM never discussed with DevOps PMs
- Positions in flows generate “false” conflicts, even with auto layout (whereby design positions should not be stored in the XML as they are not used for display)
- To avoid false conflicts, you can use sfdx-hardis plugin command
Integration and Scalability
As integration becomes more important, Apex will continue to play a key role. Salesforce will likely introduce tools that simplify complex integrations.
Clearer Guidelines
With more use of Apex and Flow, Salesforce might provide clearer guidelines on when to use each tool, helping organizations make better decisions.
Managing Technical Debt
As organizations build more Flows and Apex classes, managing technical debt will be crucial. Best practices for maintaining and refactoring both tools will become essential.
Nicolas Vuillamy hopes for clearer guidelines from Salesforce: “I hope that Salesforce will provide clear guidelines about when to use Flows and how to use them, and when not to use Flows, especially in organizations with many processes requiring scalability and high performance.”
Considering these factors and staying updated on trends helps you make smart choices between Apex and Flow, ensuring the best outcomes for your Salesforce projects.
Wrapping Up
Choosing between Apex and Flow for your Salesforce project is a significant decision that impacts your project’s success. Here are the key points to remember:
Understand Your Needs
- For simple tasks and quick automation, Flow is an excellent choice. It’s user-friendly and allows rapid deployment.
- For complex logic, heavy data processing, or integrations, Apex is more suitable. It provides the flexibility and performance needed for more intricate projects.
Consider Your Team’s Skills
- If your team includes non-developers, Flow enables them to contribute effectively without needing to code.
- If you have skilled developers, Apex offers advanced capabilities that can handle more sophisticated requirements.
Balance Performance and Maintenance
- Flow is easier to set up but can become complex to maintain over time.
- Apex requires more initial effort but can be easier to maintain and debug, especially with Salesforce’s robust tools.
Hybrid Solutions
- Often, the best approach is to use both tools together. Use Flow for user interactions and simple logic, while leveraging Apex for backend processing and complex integrations.
Stay Updated on Trends
- Salesforce is continually improving both Apex and Flow. Keeping up with these enhancements will help you make the best decisions for your projects.
Making the right choice between Apex and Flow can lead to more efficient, scalable, and maintainable Salesforce solutions. Philippe Ozil’s advice to start with Flow and move to Apex if necessary is a practical approach. Nicolas Vuillamy’s call for clearer guidelines from Salesforce highlights the importance of staying informed and adaptable.
By understanding the strengths and limitations of each tool, considering your project’s needs and your team’s skills, and staying up to date with Salesforce’s evolving features, you can make informed decisions that will benefit your Salesforce projects now and in the future.