This article explains what workflow infinite loops are, why they occur, and how you can prevent them when designing workflows.
What is a workflow infinite loop?
A workflow infinite loop occurs when a workflow repeatedly triggers itself or other workflows in a continuous cycle, resulting in an endless loop. This typically occurs when the conditions for triggering a workflow remain true after the workflow has made an update, causing it to restart indefinitely. Infinite loops can lead to:
- Excessive system processing
- Duplicate actions, such as sending multiple notifications
- Performance degradation
Common causes of infinite loops
Infinite loops typically occur when:
- Workflows are chained: One workflow updates a record in a way that triggers another workflow, which then triggers the first workflow again.
- Trigger conditions are too broad: For example, a workflow triggers on "any record update" without excluding the update performed by the workflow itself.
- Date-based workflows re-activate: A date property changes repeatedly, causing the workflow to restart.
How to avoid workflow infinite loops
Follow these best practices to avoid creating infinite loops:
1. Review workflow triggers carefully
- Use specific conditions to trigger workflows.
- Avoid using conditions that remain true after the workflow executes.
2. Use the Restrict other workflow triggers option
When designing a workflow, you can select the Restrict other workflow triggers option.
When selected:
- The workflow will not trigger any other workflows, except date-based workflows.
- Date-based workflows will continue to run as expected.
When not selected:
- The workflow behaves as usual and can trigger other workflows, including those that update dependent data.
Tip: Use this option for workflows that perform frequent updates or interact with critical business logic to prevent unwanted cascading triggers.
Example scenario
You have a workflow that sends an approval request when an employee updates their personal information.
Another workflow updates the employee record after the approval is granted. If the first workflow triggers on any update, this could create a loop.
Solution:
Enable Restrict other workflow triggers in the approval workflow. This ensures the approval workflow does not retrigger when the second workflow updates the record.