Wait for condition workflow activity
Summarize
Summary of Wait for condition workflow activity
The Wait for condition workflow activity in ServiceNow pauses a workflow at a specific point until the current record meets a defined condition. It continuously evaluates the condition each time the record is updated, enabling workflows to wait indefinitely for particular criteria to be satisfied. This activity is ideal for waiting on external events, such as record updates, rather than internal workflow-triggered changes.
Show less
Key Features
- Condition-Based Pause: The workflow halts until all specified conditions—either configured in the condition builder or defined via script—evaluate to true.
- Scripted Conditions: Supports advanced logic by allowing scripts that set an
answervariable to true to trigger continuation. - Timeout Option: Allows configuration of a maximum waiting duration. If the condition is not met within this timeframe, the workflow proceeds to the next activity. Duration can be set in hours, minutes, and seconds, and optionally linked to a work schedule for precise timing.
- Result Control: Workflow designers can assign a
resultvalue in the activity’s script field to determine when the activity transitions forward. - User Context: Condition checks and workflow advancement occur under the user context whose actions satisfy the condition.
Usage Recommendations
Use the Wait for condition activity to pause workflows for external events like record updates. Avoid using it to wait for changes made internally by the workflow itself; instead, consider inserting a short timer activity to allow the workflow to recognize its own updates.
Activity States
- Executing: The workflow begins processing the activity.
- Waiting: The workflow pauses and awaits the specified event or condition.
- Finished: The activity completed, with outcome determined by the result value.
- Cancelled: The activity or containing workflow was canceled.
- Error: A JavaScript error occurred; logs should be reviewed for details.
Practical Implications for ServiceNow Customers
This activity helps you design workflows that dynamically respond to real-time record changes, improving process automation by ensuring workflows only continue when required conditions are met. The timeout feature safeguards against indefinite waiting, maintaining workflow reliability. Understanding and leveraging the activity states enables effective monitoring and troubleshooting of workflow execution.
The Wait for condition activity causes the workflow to wait at this activity until the current record matches the specified condition.
The workflow evaluates the Wait for condition activity each time the current record is updated. Use this activity to pause a workflow indefinitely until a particular criteria is met by a record update. To pause a workflow for a timed duration see Timer workflow activities.
Results
The workflow designer can assign a result value using activity.result from
within a script field of the activity. The activity transitions when the result value is
true.
Input variables
| Field | Description |
|---|---|
| Condition | The workflow is paused at this activity until this condition matches the current record. |
| Condition script | If specified, the workflow is paused at this activity until this script sets the answer variable to true. |
| Enable Timeout | Option to limit the amount of time that the workflow waits for the activity to be completed before continuing. Note: Use the Enable timeout option to prevent this activity from continuing
to run. If the condition to continue is never met, a timeout value specifies when the system skips the Wait for Condition activity and goes to the next item in the workflow. You must set a Duration value to
enable a timeout. You can also select a Schedule if you want to compute the duration end date based on a specific work schedule. |
| Duration | Amount of time that the workflow waits before continuing when the Enable timeout option is selected. Enter the time to wait in hours, minutes, and seconds. If you leave this field empty, the workflow does not wait. |
States
| State | Description |
|---|---|
| Executing | The workflow engine knows to start the onExecute function of the activity. |
| Waiting | The workflow engine ignores the activity until a specific event to restart the activity is fired. |
| Finished | The activity finished running. See the result value for the outcome of the activity. |
| Cancelled | This activity, or the workflow that contains this activty, was canceled. |
| Error | A JavaScript error occurred. Review the logs for error details. |