Here’s the comprehensive solution addressing all three critical aspects:
1. Lifecycle Transition API Payload
The SetState action in Windchill 11.1 REST API requires more information than just the target state. The correct payload structure:
POST /Windchill/servlet/odata/ProdMgmt/Parts('OR:wt.part.WTPart:98765')/PTC.ProdMgmt.SetState
{
"State": "OBSOLETE",
"Comment": "End of life - superseded by new model",
"LifeCycleTemplate": "Standard Part Lifecycle"
}
Key points:
- Comment field is mandatory for most lifecycle transitions, even if not enforced in lifecycle template configuration
- LifeCycleTemplate parameter ensures correct template is used (critical if object type has multiple templates)
- State value must match exact internal name (case-sensitive): “OBSOLETE” not “Obsolete”
If your transition requires intermediate states (e.g., Released → Deprecated → Obsolete), you must transition through each state sequentially. The API doesn’t support skipping intermediate states even if the lifecycle template allows it in UI.
2. Required Fields for State Change
Validation failures typically occur due to state-specific attribute requirements:
A. Lifecycle Template Configuration:
Navigate to Site > Utilities > Lifecycle Administrator. Select your lifecycle template and check the Obsolete state definition:
- Required attributes: Any attributes marked required for Obsolete state must be populated before transition
- Approval requirements: If Obsolete state requires approval, you must complete approval workflow first
- Validation rules: Custom validation rules execute during transition and can block it
B. Common Required Fields for Obsolete Transition:
// Pseudocode - Complete transition payload:
1. Fetch current part object to verify current state
2. Build payload with mandatory fields:
- State: target state name
- Comment: reason for transition (100+ chars recommended)
- ObsoleteReason: if custom IBA exists
- ReplacementPart: reference to superseding part (if applicable)
3. Validate no active change orders reference the part
4. POST SetState action with complete payload
5. Verify transition success with GET request
// See documentation: Windchill Lifecycle API Guide Section 7.4
C. Dependency Validation:
Before transitioning to Obsolete, verify:
SELECT COUNT(*) FROM ChangeActivity2 ca
JOIN ChangeableLink2 cl ON ca.ida2a2 = cl.ida3a6
WHERE cl.ida3b4 = 98765 AND ca.statestate IN ('INWORK','UNDERREVIEW')
If count > 0, active change orders reference the part and block Obsolete transition. Complete or remove these references first.
3. REST vs UI Behavior Differences
The UI provides capabilities that REST API doesn’t automatically handle:
UI Advantages:
- Wizard-based flow: UI presents multi-step wizard that collects required information progressively
- Auto-population: UI automatically fills certain fields (modifier, modification timestamp) that API expects explicitly
- Validation feedback: UI shows which specific fields are missing; API returns generic “validation failed”
- Dependency resolution: UI can prompt to resolve dependencies (e.g., complete change orders); API just fails
REST API Requirements:
To achieve UI-equivalent functionality via API:
-
Pre-transition validation:
- Query object’s current state and lifecycle template
- Fetch all required attributes for target state
- Check for active dependencies (change orders, baselines, where-used)
- Verify user has transition permission
-
Complete payload construction:
- Include all required fields explicitly
- Add Comment even if not strictly required
- Specify LifeCycleTemplate to avoid ambiguity
- Include any custom IBA attributes that become required in target state
-
Error handling:
- Parse validation error details from MethodServer.log (API response is often generic)
- Implement retry logic for transient failures
- Provide meaningful error messages to end users
Common Gotchas in 11.1:
-
Workflow-driven transitions: If lifecycle template has workflow attached to Obsolete state, you must use different approach:
POST /Windchill/servlet/odata/ProdMgmt/Parts('OR:wt.part.WTPart:98765')/PTC.ProdMgmt.Promote
{
"Comment": "Initiating obsolescence workflow"
}
This starts workflow instead of direct state change.
-
Baseline references: Parts referenced in product baselines cannot transition to Obsolete until removed from baseline or baseline is marked historical
-
View management: If using view-managed parts, you must transition all view instances to maintain consistency
Debugging Steps:
- Enable lifecycle debug logging: `log4j.logger.wt.lifecycle=DEBUG
- Check MethodServer.log during failed transition for detailed validation messages
- Compare part’s lifecycle template in UI vs what API is using (might be using wrong template)
- Test transition in UI while monitoring logs to see what additional data UI provides
- Use Windchill REST API explorer to see full schema for SetState action
Complete Working Example:
POST /Windchill/servlet/odata/ProdMgmt/Parts('OR:wt.part.WTPart:98765')/PTC.ProdMgmt.SetState
Content-Type: application/json
{
"State": "OBSOLETE",
"Comment": "Product discontinued - no longer manufactured. Superseded by part P-2025-NEW.",
"LifeCycleTemplate": "Standard Part Lifecycle"
}
If this still fails, the issue is likely:
- Active change order references (resolve first)
- Custom validation rule in lifecycle template (check template configuration)
- Required custom IBA attribute for Obsolete state (check type definition)
Run the dependency query above and check lifecycle template configuration carefully. The validation error should disappear once all required fields and dependencies are addressed.
This draft is based on general Windchill knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.