04

Working with Sub-Workflows

Modular Design with Parent-Child Relationships

🎯 Learning Objectives

Upon completion of this module, you will be able to:

Understanding Sub-Workflows

A sub-workflow is a child business process initiated by a parent workflow. Sub-workflows help meet complex business requirements without adding unnecessary complexity to existing workflows.

Sub-Workflow Relationships

πŸ“‹ Key Requirement

Sub-workflows must be configured on the same base record type as the initiating parent workflow. For example, if parent runs on Purchase Order, sub-workflow must also run on Purchase Order.

The Initiate Workflow Action

Use the Initiate Workflow action to start a sub-workflow from a parent workflow. This allows multiple workflows to process in parallel on the same record.

Design Approaches

Reasons to Split Workflows

Approach Description Use Case
Loose Coupling Workflows process independently Sequential processing without dependencies
Tight Coupling Workflows have processing dependencies Sequential processing with dependencies
Parallel Processing Multiple workflows run simultaneously Parallel approvals, concurrent tasks

Loose Coupling

Loose coupling is when one component is not dependent on any other component. Each workflow processes independently and asynchronously.

LOOSE COUPLING PATTERN

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚ Workflow X β”‚ ← Parent (orchestrator)

β”‚ State 1 β”‚

β”‚ [Initiate A]β”‚

β”‚ State 2 β”‚

β”‚ [Initiate B]β”‚

β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

↓ ↓

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚Workflow Aβ”‚ β”‚Workflow Bβ”‚

β”‚(processesβ”‚ β”‚(processesβ”‚

β”‚ alone) β”‚ β”‚ alone) β”‚

β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Workflow X is the orchestrator with minimal business logicβ€”its purpose is to initiate sub-workflows A and B in sequence.

Tight Coupling

Tight coupling creates processing dependencies between workflows while still allowing sequenced execution.

TIGHT COUPLING PATTERN

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚ Workflow X β”‚

β”‚ State 1 β”‚

β”‚ [Initiate A]│───→ Workflow A completes

β”‚ β”‚ β”‚

β”‚ State 2 β”‚β†β”€β”€β”€β”€β”€β”€β”€β”€β”˜ (waits for A)

β”‚ [Initiate B]│───→ Workflow B completes

β”‚ β”‚ β”‚

β”‚ State 3 β”‚β†β”€β”€β”€β”€β”€β”€β”€β”€β”˜ (waits for B)

β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Parent workflow X waits for child workflow A to complete before transitioning to State 2 and initiating workflow B.

βœ… Implementation

Use workflow fields or record fields to communicate completion status between parent and child workflows. Configure transition conditions to wait for specific field values.

Parallel Processing

Parallel processing runs multiple workflows simultaneously on the same record.

PARALLEL PROCESSING PATTERN

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚ Workflow X β”‚

β”‚ State 1 β”‚

β”‚[Init A & B] β”‚

β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”

↓ ↓

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚Workflow Aβ”‚ β”‚Workflow Bβ”‚

β”‚(parallel)β”‚ β”‚(parallel)β”‚

β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

↓ ↓

β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”

β”‚ Workflow X β”‚

β”‚ State 2 β”‚

β”‚(waits both) β”‚

β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Parallel Approvals

A common use case where all approvals in both parent and child workflows must be completed before final approval is granted.

Synchronous vs. Asynchronous Processing

Type Behavior Use Case
Synchronous Parent waits for child to complete before continuing Tight coupling, sequential dependencies
Asynchronous Parent continues processing immediately after initiating child Loose coupling, parallel processing

πŸ’‘ Design Principle

Componentizationβ€”breaking complex workflows into smaller componentsβ€”reduces complexity of any single workflow and results in easier maintenance.

Implementation Considerations

Data Sharing Between Workflows

⚠️ Important

To pass data between parent and child workflows, use standard or custom record fieldsβ€”not workflow instance or state fields.

Best Practices

🌟 Key Takeaways