Excessive flow complexity
Why is this an issue?
Flows with too many decision elements become difficult to:
Understand: Complex branching logic is hard to follow.
Test: More paths require more test scenarios.
Maintain: Changes risk unintended consequences.
Debug: Tracing execution through many decisions is tedious.
Past a certain complexity threshold, consider refactoring into multiple flows or moving logic to Apex.
Examples
Example of incorrect flow (too many decisions):
<Flow>
<decisions>
<name>Check_Status</name>
<!-- Decision 1 -->
</decisions>
<decisions>
<name>Check_Amount</name>
<!-- Decision 2 -->
</decisions>
<!-- ... 10+ more decision elements ... -->
<decisions>
<name>Check_Region</name>
<!-- Decision 12 -->
</decisions>
</Flow>
Example of correct approach (split into subflows):
<!-- Main Flow -->
<Flow>
<subflows>
<name>Validate_Input</name>
<flowName>Validation_Subflow</flowName>
</subflows>
<subflows>
<name>Process_Record</name>
<flowName>Processing_Subflow</flowName>
</subflows>
</Flow>
How can I fix violations?
Split into subflows: Break complex flows into smaller, focused subflows.
Use Apex for complex logic: Move intricate decision logic to Apex, where it's easier to test and maintain.
Simplify conditions: Combine related decisions or use formulas to reduce branching.
Review requirements: Sometimes complex flows indicate unclear or overengineered requirements.
Configuration options
You can configure the maximum allowed number of decisions per flow. The default maximum is 3.
When should I disable this rule?
You may dismiss specific violations for flows that genuinely require complex decision trees, such as sophisticated approval routing.
Resources
