What’s trending
UPCOMING EVENTS
How Do Salesforce Flow Wait Elements Work? Use Cases, Examples, and Best Practices
By Ravi Teja
The “Wait for Amount of Time”, “Wait Until Date”, and “Wait for Conditions” Flow elements in Salesforce are powerful automation tools designed to enhance the flexibility and precision of automated processes. Technically, these elements enable Autolaunched Flows to pause execution for a predefined duration, until a specific calendar date, or until certain criteria are met, thus introducing controlled delays within business workflows.
For instance, the Wait for Amount of Time element allows processes to pause briefly – minutes, hours, or even days – making it ideal for scenarios like scheduling follow-up communications or reminders. Similarly, Wait Until Date is perfect for deferring actions to align precisely with critical business dates such as contract renewals, payment deadlines, or marketing campaign launches. The Wait for Conditions element introduces even more dynamic behavior, pausing Flow execution until specific conditions within Salesforce records are met.
From a business perspective, leveraging these Wait elements significantly enhances efficiency, accuracy, and customer engagement. Collectively, these Flow elements enable organizations to automate more sophisticated and responsive business processes that align seamlessly with operational goals and customer expectations. Let’s dive in!
Flow: Wait for Amount of Time
How It Works
The Wait for Amount of Time element enables you to pause a Flow for a defined period, with valid durations including minutes, hours, days, and months. Additionally, you can configure it to resume at a specific time of day.
While this may appear to be a completely new feature, it’s worth noting that achieving a similar outcome was already possible using the Pause element. Previously, you could create a date/time formula that calculates a future date (e.g. three months ahead) and set that as the resume time for the Pause element. The introduction of the Wait for Amount of Time element, however, significantly streamlines this configuration, making the setup process more straightforward and intuitive.
Why Use the Wait Element?
- Apex Limitation: Apex does not support sleep, pause, or wait functions, meaning you cannot put a thread on hold.
- Simulating a Pause: By using an Autolaunched Flow with Wait elements, you can create a solution that mimics the behavior of a sleep function.
Key Features
- Fixed Wait Duration: Specify the wait time in minutes, hours, days, or months before the Flow resumes.
- Resume at a Specific Time: You can configure the Flow to resume at a particular time of day.
- Automatic Resumption: The Flow continues execution once the wait period ends.
Considerations for Using Wait Elements in Flows
While the ability to pause flows is powerful, it also comes with important design considerations:
- Limited to Certain Flow Types: Only Autolaunched and Scheduled Flows support Wait elements.
- Subflow Restrictions: If a Record-Triggered Flow calls an Autolaunched Flow as a Subflow, the Subflow must not contain a wait element. Otherwise, an error will occur because Record-Triggered Flows do not support pauses.
Below is an example that leverages the Wait for Amount of Time element to send a Contract Sign Reminder Email to customer.
Flow: Wait Until Date
The Wait Until Date element in Salesforce Flow allows you to pause a Flow interview until a specified date and time before resuming subsequent actions. This feature is particularly useful for scheduling time-dependent operations within your automated processes.
Key Features of the Wait Until Date Element
- Resume Date and Time: You can define a specific date and time for the Flow to resume. This can be set using a static value or dynamically through variables or formulas, providing flexibility based on your business requirements.
- Time Zone Specification: The element allows you to specify the time zone for the resume time, ensuring that the Flow operates accurately across different regions.
Below is an example that leverages the Wait Until Date element to send a Reminder Email to Opportunity Owner.
Use Cases
- Scheduled Notifications: Send reminders or follow-up emails to customers at predetermined future dates.
- Task Automation: Delay certain tasks or actions until a specific date, such as initiating a contract renewal process a month before the contract’s end date.
Flow: Wait for Conditions
The Wait for Conditions element in Salesforce Flow allows you to pause a Flow interview until specific conditions are met before resuming subsequent actions. This functionality is particularly useful for creating time-dependent or event-driven processes within your automated workflows.
Key Features of the Wait for Conditions Element
- Conditional Pausing: You can define specific criteria that must be satisfied for the Flow to resume. This enables the Flow to wait until certain field values change or specific events occur.
- Time-Based Resumption: In addition to waiting for conditions, you can set a maximum wait time by specifying a base time, an offset number, and a unit (such as minutes, hours, or days). This ensures that the Flow doesn’t pause indefinitely if the conditions aren’t met within a reasonable timeframe.
- Multiple Configurations: The element supports adding multiple wait configurations, allowing for complex scenarios where the flow can resume upon meeting any one of several sets of conditions.
Below is an example that leverages the Wait for Conditions element to send a Contact Activation Email if a related task is completed.
Use Cases
- Approval Processes: Pause the Flow until a record receives the necessary approvals, ensuring that subsequent actions only occur after authorization.
- Status Monitoring: Wait until a related record reaches a specific status before proceeding, such as waiting for a shipment status to update to “Delivered” before sending a follow-up survey.
- Event-Driven Actions: Pause the Flow until a platform event message is received, enabling integration with external systems or processes.
What Are Paused Interviews in Scheduled Flows?
Paused interviews occur when a Flow’s execution is put on hold mid-way, waiting to continue later. In Salesforce Flow Builder, a Flow interview can pause at a Wait element – for example, Wait for Amount of Time, Wait Until Date, or Wait for Conditions. In a Scheduled Flow (an Autolaunched Flow that runs at set times), using one of these Wait elements will halt the Flow’s progress and save its state, effectively pausing the interview until the specified time or condition is met. This allows the Flow to perform actions after a delay or when certain criteria are satisfied, rather than everything happening in one execution.
Key Considerations and Potential Issues When Using Wait Elements and Paused Interviews
- Using Wait elements ends the current transaction and starts a new one upon resumption, which can reset governor limits.
- While org-wide limits on paused interviews have been removed, storage can still be a factor.
- Robust error handling (Fault Paths) and monitoring the Paused and Failed Flow Interviews list view are crucial. Administrators should know how to manually resume or delete paused interviews.
- Updating a Flow with paused interviews means the resumed interviews will run on the older version
Best Practices for Managing and Monitoring Paused Interviews
- Prioritize simplicity in Flow design. Clearly define entry and exit criteria. Use descriptive naming for Wait elements.
- Consider breaking down complex processes into smaller Flows or Subflows. Regularly review the Paused and Failed Flow Interviews list view and consider custom list views.
- Monitor the Time-Based Workflow queue for relevant Wait elements. The Automation Lightning App provides centralized monitoring.
- For troubleshooting, examine Flow logic, verify conditions for Wait for Conditions elements, review debug logs, and check time zone settings for Wait Until Date elements.
Limitations and Governor Limits Related to Wait Elements and Paused Interviews
- Resumed Flow Interviews are subject to asynchronous Apex governor limits. There’s a limit on resumed Flow interviews per hour.
- While the org-wide limit on paused interviews is removed, storage is still a concern. Follow Flow design best practices to stay within limits. Consider using Apex actions for complex operations.
Comparison of Salesforce Flow Wait Elements
Wait Element Name | Functionality | Key Configuration Options | Primary Use Cases | Flow Types |
---|---|---|---|---|
Wait for Amount of Time | Pauses for a specified duration | Minutes, Hours, Days, Months; Optional specific time of day | Follow-up emails, case escalation, scheduled reminders | Autolaunched, Schedule-Triggered |
Wait Until Date | Pauses until a specific date and time | Specific date and time; Time zone | Scheduled reminders, processing on a future date, seasonal promotions | Autolaunched, Schedule-Triggered |
Wait for Conditions | Pauses until conditions are met | Specific time, Platform Event Message, Record Conditions | Onboarding completion, approval process integration, order processing, event handling | Autolaunched, Schedule-Triggered, Orchestrations |
Summary
This article has hopefully helped you understand how to utilize Lightning Flow’s Wait elements which enable flows to pause execution until a specific condition is met, such as a time delay or an external event.
These features improve efficiency, reduce dependency on custom development, and streamline flow automation. Make sure to leave your feedback in the comments below!
Comments: