StageDefinition configures the states, transitions, criteria, and fulfillment work used by Stage Management for an object's stage field. It combines rules for changing stages with permission requirements and work definitions; it is more than a list of stage labels.
referenceObject identifies the associated object, and referenceObjectField identifies its stage field. An optional referenceObjectRecordType associates the definition with a record type. The required active setting explicitly controls whether the definition is active; the component's presence alone does not establish activation.
Key Elements
Criteria and fulfillment groups can appear under both stageValue and stageTransition. The nested element names below apply in either location unless stated otherwise.
| Element | What the Element Controls |
|---|---|
active |
Required boolean. Indicates whether the stage definition is active: true or false. |
referenceObject, referenceObjectField, referenceObjectRecordType
|
The associated object, its stage field, and an optional associated record type. The object and field are required. |
stageValue |
Defines individual stage values. Each entry requires value and can contain its own criteria and stepGroup entries. |
stageTransition |
Defines a directed stage change through required fromStageValue and toStageValue values. Each transition can have criteria, permission requirements, and fulfillment groups. |
customPermission, userPermission
|
Transition-level authorization to initiate a stage change. userPermission allows CoordinateClinicalTrials, CoordinateClnclTrialExprcUsr, ManageClinicalTrials, ParticipateClinicalTrials, or ProcessOrder. |
criteria.executionType, criteria.flowDefinitionName
|
executionType is required. CONDITION uses field-based conditions; FLOW uses the Flow identified by its developer name in flowDefinitionName. |
criteria.criteriaType, criteria.logicalExpression
|
Combines condition-based criteria using AND, OR, or CUSTOMLOGIC. logicalExpression supplies custom logic. |
criteria.condition |
Each condition requires sourceField, operator, value, and sequenceNumber. Operators are Contains, DoesNotContain, Equals, GreaterOrEqual, GreaterThan, LessOrEqual, LessThan, NotEqualTo, and StartsWith. |
criteria.targetObject, criteria.isChildObject, criteria.targetFieldName
|
Identifies the target object in a parent-child relationship, whether it is a child object, and the target field evaluated by the criteria. |
criteria.errorMessage |
The custom message displayed when stage-transition criteria evaluation fails. |
stepGroup |
Contains named groups of fulfillment steps. Each group requires name and can contain step entries. |
step.apiName, step.name, step.stepType
|
Required step identity, name, and fulfillment type. apiName is the developer name. The documented example uses AutoTask and ManualTask, but these are not an exhaustive list of allowed types. |
step.executeOnRule |
Identifies an expression set. The step executes only when that expression set evaluates to true. |
step.flowDefinitionName, step.omniscriptName, step.integrationDefinitionName
|
Identifies automation or integration associated with a fulfillment step. Despite its name, integrationDefinitionName is documented as an integration provider definition ID. |
step.assignedToQueue, step.assignedToUser, step.runAsUser, step.dependency
|
Separates work assignment, execution identity, and dependencies between steps. Each dependency requires a step value. The documented example references another step's apiName. |
Behavior and Constraints
Stage rules and transition rules are separate. A stageValue describes an individual stage, while a stageTransition describes movement from one stage to another. Both can contain criteria and fulfillment groups. When diagnosing a rejected stage change or unexpected work, inspect both locations rather than treating one as a substitute for the other.
Permission requirements govern who can initiate the change. A transition's customPermission identifies a required custom permission, and userPermission identifies a required user permission. These settings do not establish whether a particular user has the permissions. They also do not select the user who executes fulfillment steps.
Criteria can use conditions or a Flow. Every criteria entry requires executionType. With CONDITION, conditions compare sourceField with value using the selected operator. sequenceNumber specifies a condition's order within the condition sequence. That order is separate from dependencies between fulfillment steps.
With FLOW, criteria.flowDefinitionName identifies the Flow by developer name. This is distinct from step.flowDefinitionName, which identifies a Flow associated with fulfillment work.
Criteria can evaluate related records. For parent-child relationship criteria, targetObject identifies the related object, isChildObject indicates whether it is a child object, and targetFieldName identifies the evaluated field. These settings matter when the stage change depends on related records rather than only on the reference object's own fields.
A criteria failure message can be configured text. If a rejected transition displays a message, inspect errorMessage. The message can originate in the stage definition rather than being a fixed platform error.
Assignment and execution identity are different. assignedToQueue and assignedToUser describe work assignment. runAsUser identifies the user required to execute the step. Neither the assignment fields nor the transition's permission requirements should be treated as substitutes for runAsUser.
Step dependencies use a separate configuration structure. Dependencies are entries under step.dependency, each with a required step value. Salesforce's example uses another step's apiName, not its display name. A step's developer identity therefore matters independently of its name; list position or condition sequence numbers do not define these dependencies.
Deployment and Retrieval
StageDefinition components use the .stageDefinition suffix and reside in the stageDefinitions folder. The type extends Metadata and inherits fullName. The required masterLabel is the user-friendly component name, not the inherited identity field.
The package.xml manifest supports the wildcard * for this type. A manifest type entry can use <members>*</members> with <name>StageDefinition</name>. See Deploying and Retrieving Metadata with the Zip File for manifest usage.
Stage values, transitions, criteria, groups, steps, and step dependencies are nested configuration within the StageDefinition component, not separate components in its manifest entry. Required nested fields still matter: transitions require both endpoints; criteria require executionType; conditions require their field, operator, comparison value, and sequence number; groups require a name; and steps require apiName, name, and stepType.
The connections relevant to deployment depend on the values actually configured. They can include the reference object and field, an associated record type, transition permissions, criteria Flows, fulfillment automation, expression sets, and user or queue identities. A definition using only field conditions has different configured connections from one that invokes Flows, OmniScripts, or integrations.
Do not infer an identifier format from an element's name. In particular, integrationDefinitionName is documented as an integration provider definition ID, not a developer name. runAsUser also has an identifier-format ambiguity described below; it should not be assumed to be a portable developer-name reference.
Relationships
The reference object and its stage field establish the definition's scope, optionally with a record type. Criteria connect stage evaluation to object fields, related records, or a Flow. Transitions connect stage changes to custom and user permission requirements. Fulfillment steps connect the definition to Flows, OmniScripts, integration provider definitions, expression sets, users, and queues. Within the component, dependency entries connect fulfillment steps by the step identity shown in the documented example.
Documentation Inconsistencies
runAsUser has a consequential discrepancy in Salesforce's documentation. Its field definition describes a user ID, but the declarative example supplies a username, testuser@salesforce.com. The example does not establish that the field is a portable developer-name reference. Keep this distinction in mind when diagnosing execution identity or moving a definition between orgs.
Common Questions
How do I retrieve StageDefinition metadata?
Use StageDefinition as the type name in package.xml. The type supports * in members. Its components use the .stageDefinition suffix in the stageDefinitions folder.
Why is a stage change rejected even though the stage value exists?
A stage value is only part of the configuration. The directed transition can have its own criteria and permission requirements, and stage-level criteria are a separate location to inspect. A displayed failure message can come from criteria.errorMessage.
Does assigning a fulfillment step to a user determine who runs it?
No. assignedToUser and assignedToQueue describe assignment, while runAsUser identifies the execution user. Transition permissions separately control authorization to initiate the stage change.
Can I deploy a stage transition or fulfillment step as a separate component?
Transitions, stage values, criteria, groups, steps, and dependencies are nested within StageDefinition. They are configuration inside that component rather than separate components in its manifest entry.
Are the criteria Flow and fulfillment Flow the same setting?
No. criteria.flowDefinitionName identifies the Flow used when criteria have executionType set to FLOW. step.flowDefinitionName identifies a Flow associated with fulfillment work.