StageAssignment defines an automatic selection policy for assigning a StageDefinition to a Salesforce record. It scopes the policy to an object and, optionally, a record type, then uses conditions and priorities to select a stage definition when a record is created or updated.
Do not confuse assignment policy with stage behavior. StageDefinition defines the stages, transitions, and workflows. StageAssignment determines which definition applies to a record; it does not define those stages or transitions itself.
Key Elements
The elements inside ruleCriteria belong to an individual criterion. Elements inside condition belong to an individual field comparison.
| Element | What the Element Controls |
|---|---|
active |
Required Boolean that controls whether the assignment participates in evaluation. The documented default is true. |
referenceObject |
Required API name of the Salesforce object to which the assignment applies, such as ApplicationForm or Order. |
referenceObjectRecordType |
Optional restriction to records of a specified record type on the reference object. |
ruleCriteria |
Collection of nested StgAssignmentRuleCriteria definitions. The first matching criterion selects the stage definition. |
priority |
Required integer within each criterion. Lower numbers are evaluated first. This orders criteria within the collection, not separate StageAssignment components. |
criteriaType |
Required condition-combination mode within each criterion. Allowed values are AND, OR, and CUSTOMLOGIC. |
logicalExpression |
Custom Boolean expression used when criteriaType is CUSTOMLOGIC. It refers to conditions by their sequenceNumber. |
fieldName |
Required API name of the field evaluated by a condition. |
operator |
Required comparison operator. Allowed values are Contains, DoesNotContain, Equals, GreaterOrEqual, GreaterThan, LessOrEqual, LessThan, NotEqualTo, and StartsWith. |
sequenceNumber |
Required integer identifying a condition in a custom logical expression. It is not the criterion's evaluation priority. |
value |
Required comparison value, serialized as a string regardless of the field's data type. |
stageDefinition |
At the top level, the optional fallback when no criterion matches. Within each criterion, the required API name of the target StageDefinition, which must be valid for the same reference object. |
Behavior and Constraints
Activation and scope
When a record is created or updated, the system evaluates active StageAssignment rules for its object. Setting active to false excludes that assignment from evaluation.
referenceObject establishes the object scope. If referenceObjectRecordType is also specified, the rule applies only to records of that record type. Conditions select a stage definition within that scope; they do not replace the object or record-type restriction.
First match and fallback
The system evaluates ruleCriteria in ascending priority order. A criterion with priority 1 is evaluated before one with priority 2. The first matching criterion determines the assignment, so an earlier broad match can prevent a later, more specific criterion from selecting its target.
For example, a criterion that matches all approved records can take precedence over a later criterion intended only for high-value approved records. The later criterion's conditions do not make it more important than an earlier match.
If no criterion matches, the top-level stageDefinition supplies the fallback when configured. This is separate from the stageDefinition inside each criterion. A matching criterion selects its own target rather than the fallback.
priority controls evaluation within one criteria collection. It is not a documented ordering mechanism across separate StageAssignment components.
Condition logic and value serialization
Each criterion contains a condition collection. Use AND to require all conditions, OR to accept any condition, or CUSTOMLOGIC to combine numbered conditions through logicalExpression.
For example, 1 AND 2 refers to conditions whose sequenceNumber values are 1 and 2. These numbers identify conditions in the expression; they do not set the criterion's priority.
Each condition compares fieldName against value using operator. The metadata stores value as a string even for numeric or date comparisons. Values such as 10000, 2025-10-27, and Approved are all serialized as strings. That representation does not make the underlying field a text field.
Deployment and Retrieval
StageAssignment components use the .stageAssignment suffix and reside in the stageAssignments folder. The type extends Metadata and inherits its fullName field.
In package.xml, use StageAssignment as the type name. The type supports the wildcard member *. See deploying and retrieving metadata with a ZIP file for manifest usage.
The component requires active, masterLabel, and referenceObject. Each nested criterion requires name, priority, criteriaType, and stageDefinition. Each condition requires fieldName, operator, sequenceNumber, and value.
Each criterion's target must be the API name of a valid StageDefinition for the same reference object. Keep that requirement distinct from the criterion's name and the assignment's user-facing masterLabel.
StgAssignmentRuleCriteria and StgAssignmentRuleCond are nested definitions within the assignment, not separate assignment assets. Their configuration belongs inside the StageAssignment component.
Changing activation, object or record-type scope, priorities, conditions, or target definitions can change the stage definition selected during record creation or update. To change the stages, transitions, or workflows themselves, change the referenced StageDefinition instead.
Relationships
An assignment connects an object, an optional record-type restriction, evaluated fields, and the stage definitions selected by matching criteria or fallback. The nested criteria and conditions hold the selection logic.
References
-
StageDefinition:stageDefinitionat the top level and withinruleCriteria. Criterion targets must be valid for the samereferenceObject.
Common Questions
Why is StageAssignment selecting the wrong stage definition?
Check the object and record-type scope, then inspect criteria in ascending priority order. The first match wins. An earlier broad criterion can prevent a later, more specific criterion from selecting its target.
Why is the default stageDefinition not being used?
The top-level stageDefinition is a fallback used only when no criterion matches. If a criterion matches, its nested stageDefinition determines the assignment.
What is the difference between priority and sequenceNumber?
priority orders criteria within ruleCriteria, with lower numbers evaluated first. sequenceNumber identifies a condition for use in logicalExpression, such as 1 AND 2.
How do I retrieve StageAssignment metadata?
Use StageAssignment as the type name in package.xml; the wildcard member * is supported. Components reside in stageAssignments and use the .stageAssignment suffix.
Should I change StageAssignment or StageDefinition to change a workflow?
Change StageAssignment to change which definition a record receives. Change StageDefinition to change the stages, transitions, or workflows defined by that target.