Skip to main content
Version: 1

Executing Flow Steps

info

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 isDone output variable for repeat functionality

Step Lifecycle

Flow steps follow a simple lifecycle:

  1. Queued - Step is scheduled for execution
  2. Running - Flow executes in its own container
  3. Completed - Flow finishes successfully or with errors
  4. Output Available - Results are available for subsequent steps

Creating Your Flow Step

1. Flow Configuration

Create an Autolaunched Flow with the following structure:

  1. Input Variables: Define variables to receive data from previous steps
  2. Flow Logic: Your business logic, decisions, assignments, etc.
  3. Output Variables: Define variables to pass data to subsequent steps
  4. Repeat Logic: Include an isDone variable 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 isDone for repeat logic

4. Repeat Logic Implementation

For flows that need to execute repeatedly, implement the isDone logic:

  1. Create an isDone Output Variable: Boolean type, output only
  2. Set Default Value: Usually false to start
  3. Implement Completion Logic: Set isDone to true when 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:

  1. Input Variables:

    • counter (Number) - Current count
    • targetCount (Number) - Target to reach
  2. Flow Logic:

    • Increment the counter
    • Check if target is reached
    • Set isDone based on completion
  3. Output Variables:

    • counter (Number) - Updated count
    • isDone (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:

  1. Decision: Check if counter equals 10
  2. If Yes: Set isDone to true (stop repeating)
  3. If No: Increment counter by 1 and set isDone to false (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:

  1. Try-Catch Elements: Use fault paths to handle exceptions
  2. Decision Elements: Check for error conditions
  3. Assignment Elements: Set error status variables
  4. 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

  1. Single Responsibility: Each flow should perform one well-defined operation
  2. Input Validation: Always validate and handle null inputs
  3. Meaningful Outputs: Return structured data that's useful for subsequent steps
  4. Error Handling: Implement proper error handling and recovery

Performance

  1. Batch Processing: Process data in batches to stay within limits
  2. Efficient Queries: Use selective SOQL queries and bulk operations
  3. Memory Management: Avoid storing large objects in memory
  4. Use Repeat Logic: For large datasets, use repeat logic to process in chunks

Variable Naming

  1. Descriptive Names: Use clear, descriptive variable names
  2. Consistent Naming: Follow consistent naming conventions
  3. Documentation: Document complex variables and their purposes
  4. Type Safety: Ensure variable types match expected data

Testing

  1. Unit Tests: Test your flow with various input scenarios
  2. Edge Cases: Test with null values, empty collections, and error conditions
  3. Integration Tests: Test your flow within the orchestration context
  4. 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 process
  • batchSize (Number) - Number of accounts to process per batch
  • processedCount (Number) - Total accounts processed so far

Output Variables

  • processedAccounts (Record Collection) - Accounts processed in this batch
  • processedCount (Number) - Updated total count
  • isDone (Boolean) - Whether processing is complete

Flow Logic

  1. Get Records: Query accounts of the specified type, limited by batch size
  2. Process Records: Update account fields as needed
  3. Update Count: Add processed records to the total count
  4. Check Completion: If processed count >= 1000, set isDone to true
  5. 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.