1. Core Substitution Context
  2. Stub State

Core Substitution Context

Stub State

Provides the current stub state from the core substitution context. Useful for state-aware actions, conditional logic, and workflow automation.

A stub's state represents its current point in a template's flow. Each stub can only be in one state at a time, and that state determines which actions are available and what can happen next in the process.

Referencing the current state allows action definitions, messages, and integrations to respond dynamically as a stub progresses through its workflow. For more information about how states work, see States and Actions.

Usage

Use the substitution ~~stub.state in your action definitions to dynamically insert the current state of the stub. This is particularly useful for state-aware tasks that need to identify where a stub is in its workflow.

Example 1: Saving the Current State

Action definition:

loading...

Substituted definition:

Assuming the stub is currently in the awaiting-payment state:

loading...

In this example, the ~~stub.state substitution is replaced with the current state of the stub (awaiting-payment). The value is saved to stub.data.state_at_last_update, allowing it to be used later for logging, reporting, or workflow logic without hardcoding the state name.

Example 2: Retaining the Current State When Morphing

Action definition:

loading...

Substituted definition:

Assuming the stub is currently in the awaiting-payment state:

loading...

In this example, the ~~stub.state substitution is replaced with the current state of the stub (awaiting-payment). This allows the stub to retain its current state when it is morphed to the live branch without hardcoding the state name in the action definition. The state must also exist in the target program.