Previous Next JavaScript must be enabled to correctly display this content

## 20.1.6 States and Transitions

Learn about states and transitions for workflows and for workflow activities.

- Workflow States and Transitions
  Learn about available workflow states and potential transitions.
- Activity States and Transitions
  Learn about available activity states and potential transitions.

Parent topic: About Workflows

### 20.1.6.1 Workflow States and Transitions

Learn about available workflow states and potential transitions.

Workflow States

A workflow state is the current state of a workflow instance. There are five separate workflow states, and a workflow may only be in one state at a time.

Active

  A workflow that is currently running.

Suspended

  A workflow that is currently suspended at a particular activity. A suspended workflow can be resumed by the Workflow Administrator.

Completed

  A workflow that has reached an end activity and completed successfully.

Terminated

  A workflow that has been stopped by the Workflow Owner or Workflow Administrator or a workflow that has reached an end activity with the state attribute set to terminated.

Faulted

  A workflow that produced an error at one of its activities. The Workflow Administrator can retry or stop a faulted workflow.

Workflow State Transitions

A workflow transition describes a workflow moving from one state to another. Workflow state transitions happen either by the workflow engine itself, by appropriate APIs, or as a result of a user action. For example, a workflow may transition from Active to Completed after a user approves a task.

Initial State | Category | Possible Transitions
--- | --- | ---
Active | Normal | Completed, when the workflow reaches an end activity. Faulted, when the creation of the workflow instance fails due to parameters that cannot be handled correctly, if there is more than one start activity, or if there is no start activity. Suspended, per API or user request. Terminated, per API or user request, or because the workflow reaches an end activity that moves the workflow to a terminated state.
Completed | Normal | None.
Faulted | Exception Tip: Workflows transition to faulted if an activity cannot run successfully or if there is an error in the workflow itself due to a failure to retrieve workflow variables or a system error. Faulted workflows can be retried after modifying variables, or terminated if the user wants to end the workflow instance and no longer run the workflow. | Active, when the workflow is retried by API or user request and retrying successfully brings the workflow back into a normal state of operation. Suspended, per API or user request. Terminated, per API or user request.
Suspended | Normal Tip: Typically, a workflow is suspended due to a Wait activity. Tip: By default, workflows resume at the current activity. Use `APEX_WORKFLOW.RESUME` to resume the workflow at any activity. | Active, when the workflow is resumed by API or user request. Faulted, when an outstanding (asynchronous) activity returns with an error and the activity and workflow instance transition to faulted. Terminated, by API or user request.
Terminated | Exception Tip: A terminated workflow instance cannot be retried. | None.

Parent topic: States and Transitions

### 20.1.6.2 Activity States and Transitions

Learn about available activity states and potential transitions.

Activity States

An activity state is the current state of an activity. An activity can only be in one state at a time.

Active

  An activity that is currently running.

Waiting

  An activity that is currently waiting for a result. For example, an activity might be waiting on approval from a task, waiting for an invoked workflow to run, or waiting for all branches in the activity to complete.

Completed
  An activity that completed successfully.

  Tip:

  For parallel flow activities, all branches in the parallel flow must complete for the activity to transition to Completed.
Terminated

  An activity that was in active state when the workflow was stopped.

Faulted
  An activity that fails to run.

  Tip:

  If an activity in a branch of a parallel flow activity transitions to the faulted state, the parallel flow activity also transitions to faulted. Retrying the workflow retries all faulted activities in all branches of the parallel flow activity. It may be necessary to retry the workflow multiple times until all faults in all branches are fixed.

Activity State Transitions

An activity transition describes an activity moving from one state to another.

Initial State | Category | Possible Transitions
--- | --- | ---
Active | Normal | Completed, when the activity completes successfully and the workflow continues. Faulted, when the activity fails to run, either because the activity itself faulted, or because something leading into or out of the activity faulted. Terminated, when the workflow instance is terminated. Waiting, when the activity is waiting for a result to come back. For example, asynchronous activities or approval activities may move into a waiting state.
Completed | Normal | None.
Faulted | Exception | Active, when the workflow instance is retried by API or user request. Any faulted activities move to an active state and the workflow runtime engine attempts to execute the activity again.
Terminated | Exception | None.
Waiting | Normal | Active, when the activity operation is complete and signals to the workflow that it is okay to continue. The duration of this transition may be very short, so the user may never experience an activity in waiting state, even when there is a pause in the workflow. Faulted, when the activity processing fails. Terminated, when the workflow instance is terminated.

Parent topic: States and Transitions