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 activity until the current record meets a defined condition. The workflow continuously evaluates this condition each time the record is updated, allowing the workflow to wait indefinitely for particular criteria to be true before proceeding. This activity is designed to wait for external events, such as record updates, rather than changes made internally by the workflow itself.
Show less
Key Features
- Condition Evaluation: The workflow pauses until all specified conditions—either set through the condition builder or a script—are met on the current record.
- Scripted Conditions: You can specify a script that sets an
answervariable to true, which controls when the workflow continues. - Timeout Capability: An optional timeout can be enabled to limit how long the workflow waits for the condition. If the condition is not met within the specified duration (measured in hours, minutes, and seconds), the workflow skips this activity and moves forward. Timeouts can also be scheduled according to work schedules.
- Result Assignment: From within the activity’s script field, a
resultvalue can be assigned. When set to true, this causes the workflow to transition out of the waiting state. - Activity States: The activity cycles through states such as Executing, Waiting, Finished, Cancelled, and Error to communicate its current status to the workflow engine.
Practical Considerations for ServiceNow Customers
- Use this activity to effectively pause workflows until external record updates satisfy desired conditions, enabling workflows to respond dynamically to system changes.
- Avoid using this activity to wait on internal workflow-driven field changes; instead, consider inserting a short timer if waiting for such changes is necessary.
- Enable and configure timeouts to prevent workflows from stalling indefinitely if conditions are never met, ensuring smoother workflow execution and error handling.
- Understand the activity states to monitor workflow progress and diagnose issues, especially if errors occur during condition evaluation.
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. |