Executing Flow Steps
Available: Starter and Premium as a paid add-on
Audience: Administrators and Developers
Overview
Flow Steps in STEP Orchestrator provide a declarative way to execute business logic within your orchestration workflows. Flow steps leverage Salesforce's powerful Flow Builder to create complex automation without code, while maintaining the limit-safe execution benefits of the STEP Orchestrator. For information on using the Step Designer to configure Flow steps, see Using Step Designer.
Each Flow step runs in its own isolated execution container with fresh Salesforce governor limits, making it ideal for declarative automation, data transformations, and record operations that would otherwise hit platform limits.
Key Benefits
- Limit-Safe Execution: Each step runs with fresh governor limits
- Containerized Processing: Steps execute in isolation for reliability
- Declarative Logic: Build complex automation without code
- Stateful Chaining: Pass data between steps seamlessly
- Repeat Capability: Execute steps iteratively until completion criteria are met
- Error Recovery: Built-in retry mechanisms and error handling
- Visual Design: Use Flow Builder for intuitive step creation
How Flow Steps Work
Execution Container
Each Flow step executes in its own execution container, which provides:
- Fresh Governor Limits: DML, SOQL, and CPU limits reset for each step
- Isolated Processing: Steps run independently without affecting each other
- Automatic Cleanup: Resources are automatically managed and cleaned up
- Error Isolation: Failures in one step don't affect others
Flow Requirements
To work as a Flow step, your flow must be:
- Autolaunched Flow: The flow must be configured as an Autolaunched Flow
- Input Variables: Define input variables to receive data from previous steps
- Output Variables: Define output variables to pass data to subsequent steps
- Repeat Logic: Include an
isDoneoutput variable for repeat functionality
Step Lifecycle
Flow steps follow a simple lifecycle:
- Queued - Step is scheduled for execution
- Running - Flow executes in its own container
- Completed - Flow finishes successfully or with errors
- Output Available - Results are available for subsequent steps
Creating Your Flow Step
1. Flow Configuration
Create an Autolaunched Flow with the following structure:
- Input Variables: Define variables to receive data from previous steps
- Flow Logic: Your business logic, decisions, assignments, etc.
- Output Variables: Define variables to pass data to subsequent steps
- Repeat Logic: Include an
isDonevariable for repeat functionality
2. Input Variables
Define input variables to receive data from previous steps or orchestration variables:
- Variable Name: Use descriptive names (e.g.,
accountId,batchSize,processedCount) - Data Type: Match the data type of the incoming data
- Required: Mark as required if the step needs this data to function
- Default Value: Provide defaults where appropriate
3. Output Variables
Define output variables to pass data to subsequent steps:
- Variable Name: Use descriptive names that indicate the data being passed
- Data Type: Choose appropriate data types for the output
- isDone Variable: Always include a Boolean variable named
isDonefor repeat logic
4. Repeat Logic Implementation
For flows that need to execute repeatedly, implement the isDone logic:
- Create an
isDoneOutput Variable: Boolean type, output only - Set Default Value: Usually
falseto start - Implement Completion Logic: Set
isDonetotruewhen the step is complete
Repeat Logic Pattern
Basic Repeat Pattern
The most common repeat pattern involves a counter that increments until a target is reached:
-
Input Variables:
counter(Number) - Current counttargetCount(Number) - Target to reach
-
Flow Logic:
- Increment the counter
- Check if target is reached
- Set
isDonebased on completion
-
Output Variables:
counter(Number) - Updated countisDone(Boolean) - Whether to continue repeating
Example: Step_Repeat_Sample_Flow
Here's how the sample flow implements repeat logic:
<!-- Input Variable -->
<variables>
<name>counter</name>
<dataType>Number</dataType>
<isInput>true</isInput>
<isOutput>true</isOutput>
</variables>
<!-- Output Variable -->
<variables>
<name>isDone</name>
<dataType>Boolean</dataType>
<isInput>false</isInput>
<isOutput>true</isOutput>
<value>
<booleanValue>false</booleanValue>
</value>
</variables>
Flow Logic:
- Decision: Check if
counterequals 10 - If Yes: Set
isDonetotrue(stop repeating) - If No: Increment
counterby 1 and setisDonetofalse(continue repeating)
Advanced Repeat Patterns
You can implement more complex repeat logic:
- Batch Processing: Process records in batches until all are complete
- Conditional Repeats: Repeat based on business conditions
- Error Recovery: Repeat on failure with retry logic
- Progress Tracking: Track and report progress across iterations
Error Handling
Flow Error Handling
Implement proper error handling in your flows:
- Try-Catch Elements: Use fault paths to handle exceptions
- Decision Elements: Check for error conditions
- Assignment Elements: Set error status variables
- Output Variables: Return error information to the orchestration
Error Recovery
The STEP Orchestrator provides built-in error recovery:
- Automatic Retries: Failed steps can be automatically retried
- Manual Recovery: Failed steps can be manually retried through the UI
- Error Logging: Comprehensive error details are captured
- Orchestration Continuation: Other steps continue even if one fails
Best Practices
Flow Design
- Single Responsibility: Each flow should perform one well-defined operation
- Input Validation: Always validate and handle null inputs
- Meaningful Outputs: Return structured data that's useful for subsequent steps
- Error Handling: Implement proper error handling and recovery
Performance
- Batch Processing: Process data in batches to stay within limits
- Efficient Queries: Use selective SOQL queries and bulk operations
- Memory Management: Avoid storing large objects in memory
- Use Repeat Logic: For large datasets, use repeat logic to process in chunks
Variable Naming
- Descriptive Names: Use clear, descriptive variable names
- Consistent Naming: Follow consistent naming conventions
- Documentation: Document complex variables and their purposes
- Type Safety: Ensure variable types match expected data
Testing
- Unit Tests: Test your flow with various input scenarios
- Edge Cases: Test with null values, empty collections, and error conditions
- Integration Tests: Test your flow within the orchestration context
- Repeat Testing: Test repeat logic with different iteration counts
Complete Example
Here's a complete example of a flow that processes accounts in batches:
Input Variables
accountType(Text) - Type of accounts to processbatchSize(Number) - Number of accounts to process per batchprocessedCount(Number) - Total accounts processed so far
Output Variables
processedAccounts(Record Collection) - Accounts processed in this batchprocessedCount(Number) - Updated total countisDone(Boolean) - Whether processing is complete
Flow Logic
- Get Records: Query accounts of the specified type, limited by batch size
- Process Records: Update account fields as needed
- Update Count: Add processed records to the total count
- Check Completion: If processed count >= 1000, set
isDonetotrue - Set Outputs: Return processed accounts and updated count
Repeat Logic
- Continue Repeating: While
processedCount< 1000 - Stop Repeating: When
processedCount>= 1000 or no more accounts found
Common Use Cases
Data Processing
- Batch Record Updates: Process large datasets in manageable chunks
- Data Transformations: Transform data between different formats
- Record Creation: Create records based on business logic
- Data Validation: Validate and clean data
Integration
- API Callouts: Make external API calls (within limits)
- Data Synchronization: Sync data between systems
- File Processing: Process files and attachments
- Email Processing: Handle email-based workflows
Business Logic
- Calculations: Perform complex business calculations
- Decision Making: Implement business rules and decisions
- Notifications: Send notifications and alerts
- Approval Processes: Handle approval workflows
Limitations and Considerations
Flow Limitations
- Governor Limits: Each flow step still has individual governor limits
- Complexity: Very complex flows may be better implemented as Apex steps
- Debugging: Flow debugging can be challenging for complex logic
- Versioning: Flow changes require careful version management
Performance Considerations
- Execution Time: Flows have execution time limits
- Memory Usage: Large data sets may cause memory issues
- Query Limits: SOQL queries are limited per transaction
- DML Limits: Record operations are limited per transaction
Conclusion
Flow steps in STEP Orchestrator provide a powerful, declarative way to execute business logic within your orchestration workflows. By following best practices and implementing proper repeat logic, you can create robust and scalable flow implementations that leverage the full power of Salesforce Flow Builder while maintaining the benefits of limit-safe, containerized execution.
The combination of fresh governor limits, isolated execution containers, repeat logic support, and comprehensive error handling makes Flow steps an essential tool for declarative business process automation in Salesforce.
For information on creating and managing orchestrations with Flow steps, see Using Step Designer.