UTIL_AsyncChain.ChainStatus
Class
global inherited sharing class UTIL_AsyncChain.ChainStatusTyped, read-only snapshot of a chain execution returned by getChainStatus. A structured alternative to the getStatus(Id) map: each tracked field is a named property and the lifecycle is queryable through isRunning(), isTerminal() and isFailed(). Holds no step list and performs no queries — it is a plain value object built from a single AsyncChainExecution__c row.
Example
UTIL_AsyncChain.ChainStatus status = UTIL_AsyncChain.getChainStatus(executionId);
Boolean stillRunning = status.isRunning();
Integer done = status.completedSteps;Methods
| Method | Description |
|---|---|
| global Boolean isFailed() | Whether the chain failed. |
| global Boolean isRunning() | Whether the chain is currently running. |
| global Boolean isTerminal() | Whether the chain has reached a terminal state from which it will not advance — Completed, Failed or Aborted, or any row carrying a completion timestamp. |
isFailed
global Boolean isFailed()Whether the chain failed.
Returns Boolean — true when the status is Failed.
Example
if(status.isFailed()) { escalate(status.errorMessage); }isRunning
global Boolean isRunning()Whether the chain is currently running. A Stalled chain reports as neither running nor terminal: it is waiting for recovery after a temporary platform limit stopped the framework from scheduling its next piece of work, or after the SCHED_ChainWatchdog scheduled job found it silently stuck. The reserved Delayed status, which the framework does not currently write, is reported the same way.
Returns Boolean — true when the status is Running.
Example
if(status.isRunning()) { return; }isTerminal
global Boolean isTerminal()Whether the chain has reached a terminal state from which it will not advance — Completed, Failed or Aborted, or any row carrying a completion timestamp. The timestamp conjunct covers a rare recovery overwrite that can leave a finished chain reading Stalled: the completion timestamp survives that overwrite, so it is the reliable end-of-life signal.
Returns Boolean — true when the status is Completed, Failed or Aborted, or completedAt is set.
Example
if(status.isTerminal()) { notifyDone(status); }Fields
| Field | Description |
|---|---|
| global String chainName | The descriptive chain name supplied to newChain(...). |
| global Datetime completedAt | When the chain reached a terminal state; null while still in flight. |
| global Integer completedSteps | The number of steps completed so far. |
| global String correlationId | The correlation ID that ties this chain's log entries together. |
| global String currentStepName | The name of the step currently executing (or last executed), if recorded. |
| global String durationLabel | A compact, human-readable form of durationMs (for example "1m 30s"); null when no duration is available. |
| global Long durationMs | Elapsed run time in milliseconds. |
| global String errorMessage | The failure message, when the chain has failed; otherwise null. |
| global Id executionId | The AsyncChainExecution__c record ID. |
| global Datetime startedAt | When the chain started executing. |
| global String status | The lifecycle status: one of Running, Completed, Failed, Stalled or Aborted. |
| global Integer totalSteps | The total number of steps in the chain. |
chainName
global String chainNameType: String
The descriptive chain name supplied to newChain(...).
completedAt
global Datetime completedAtType: Datetime
When the chain reached a terminal state; null while still in flight.
completedSteps
global Integer completedStepsType: Integer
The number of steps completed so far.
correlationId
global String correlationIdType: String
The correlation ID that ties this chain's log entries together.
currentStepName
global String currentStepNameType: String
The name of the step currently executing (or last executed), if recorded.
durationLabel
global String durationLabelType: String
A compact, human-readable form of durationMs (for example "1m 30s"); null when no duration is available.
durationMs
global Long durationMsType: Long
Elapsed run time in milliseconds. For a still-Running chain with no persisted duration, this is computed live from startedAt, matching the Chain Monitor console.
errorMessage
global String errorMessageType: String
The failure message, when the chain has failed; otherwise null.
executionId
global Id executionIdType: Id
The AsyncChainExecution__c record ID.
startedAt
global Datetime startedAtType: Datetime
When the chain started executing.
status
global String statusType: String
The lifecycle status: one of Running, Completed, Failed, Stalled or Aborted. The framework writes Stalled when a temporary platform limit stops it from scheduling the chain's next piece of work: the chain waits for recovery instead of failing. The SCHED_ChainWatchdog scheduled job also writes Stalled when its sweep finds a chain silently stuck with no recent activity. (The picklist also defines Delayed, which the framework does not currently write.) Prefer the isRunning()/isTerminal()/isFailed() predicates over comparing this String. A Stalled value beside a populated completedAt means a recovery overwrite landed on a finished chain; isTerminal() reports that row terminal.
totalSteps
global Integer totalStepsType: Integer
The total number of steps in the chain.