Step Type: Wait For Condition
The Wait For Condition step polls a configurable data source on a fixed interval until a user-supplied expression evaluates truthy, or a timeout is reached. It is the standard way to pause a procedure until something happens on an external system before moving on.
When to Use
- Wait for a target server to finish ingesting records migrated by an earlier step (e.g. a ServiceNow Import Set transform that runs asynchronously)
- Wait for an external job — a build, an export, a backup — to report success via a status endpoint
- Wait for a record count on a target table to reach an expected value before continuing
- Wait for any other condition you can express as a formula against data PB can fetch
For a one-shot API call where you do not need to retry, use Call API Endpoint instead.
Configuration
The step has three configuration sections.
Source (the Check)
Pick what PB fetches on each polling iteration. Available check types:
| Check type | What it fetches |
|---|---|
| API Endpoint | Calls a named endpoint on a connection's adaptor. The endpoint's response is available in the until expression. |
| Record Query | Runs a filter query against a connection/table and exposes the returned records. |
| Record Count | Runs a count query against a connection/table and exposes the integer count. |
| Expression | Evaluates the until expression directly with no fetch. Useful for time-only waits or for expressions that consult only procedure variables. |
Until (the Condition)
A formula expression that PB evaluates on every iteration after the fetch. When it evaluates truthy, polling stops and the step completes successfully. The variables available to the expression are:
- All procedure variables in scope
- The keys exposed by the selected check (e.g.
response,records,count)
Examples:
count >= 100— wait until at least 100 records are presentresponse["state"] == "complete"— wait until an API status field flips to "complete"len(records) > 0 and all(r["status"] == "ready" for r in records)— wait until all matching records are ready
Timing and Error Handling
| Setting | Default | Description |
|---|---|---|
poll_interval_seconds |
5 | How often to poll. Clamped to a 1-second minimum at execute time. |
max_wait_seconds |
300 | Total wait budget before timeout handling kicks in. Capped at 3600 (one hour). |
on_timeout |
fail |
What to do if the condition is not met before max_wait_seconds elapses. fail raises an error; continue logs a warning and proceeds with result=False. |
on_fetch_error |
retry |
What to do if the check itself raises (e.g. a 5xx response). retry swallows the exception and waits for the next poll; fail re-raises immediately. |
A broken until expression is always fatal — PB does not retry on expression evaluation errors, because a misconfigured expression would otherwise loop silently forever.
Output Variables
The Wait For Condition step can populate output variables with the following calculations:
| Calculation | Type | Description |
|---|---|---|
result |
bool | True if the condition was met, False on timeout-with-continue. |
attempts |
int | Number of poll iterations performed. |
elapsed |
float | Total seconds elapsed in the polling loop. |
context |
dict | The last context dict returned by the check (response body, records, count, etc.). |
Example
A typical use case is waiting for a ServiceNow Import Set transform to finish before reading the migrated records:
- Source: API Endpoint check pointing at a status endpoint
- Until:
response["state"] == "loaded" - Poll interval: 10 seconds
- Max wait: 600 seconds (10 minutes)
- On timeout:
fail - Output variables: capture
attemptsandelapsedfor the execution report
Related Documentation
- Call API Endpoint — one-shot API calls without retry
- Iterate — for looping over a known collection rather than polling for a condition
Comments
0 comments
Please sign in to leave a comment.