Wait for condition workflow activity
Summarize
Summary of Wait for condition workflow activity
The Wait for condition workflow activity allows a workflow to pause execution until a specified condition on the current record is met. This activity continuously evaluates the condition each time the record is updated and holds the workflow indefinitely until the criteria are satisfied. It is designed to wait for external events, such as record updates, rather than changes triggered internally within the same workflow. For timed pauses, Timer workflow activities are recommended instead.
Show less
Key Features
- Condition Evaluation: The workflow pauses until all specified conditions—defined either via the condition builder or a script—return true.
- Input Variables:
- Condition: Defines the criteria that must be met on the current record.
- Condition script: Allows specifying a script that sets an
answervariable to true to meet the condition. - Enable Timeout: Optionally limits how long the workflow waits before automatically continuing if the condition is not met.
- Duration: Specifies the wait time when timeout is enabled, entered in hours, minutes, and seconds.
- Schedule: Allows computing the timeout duration based on a specific work schedule.
- Result Value: The workflow designer can assign a
resultvalue within the activity’s script; the activity transitions when this value is true. - User Context: Condition activities execute as the user whose actions meet the waiting conditions.
- Activity States: The workflow engine manages states such as Executing, Waiting, Finished, Cancelled, and Error to control the activity lifecycle.
Practical Considerations for ServiceNow Customers
- Use Wait for condition activity to pause workflows until external updates occur on records, ensuring workflows proceed only when relevant data changes.
- Avoid using this activity to wait on changes made by the same workflow; instead, insert a short timer to detect such changes.
- Enable timeout with a defined duration to prevent indefinite waiting in scenarios where conditions may never be met, maintaining workflow reliability.
- Monitor activity states and logs for errors to troubleshoot and ensure smooth 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. |