We’re experiencing issues with a Process Extension in our workflow management module where conditional logic fails when checking attribute values. The PX is designed to route ECOs based on cost impact, but it’s throwing errors when the cost attribute is null or not yet populated.
The workflow step execution halts completely instead of following the default path. Our PX conditional logic checks the ‘Estimated_Cost’ attribute and should route high-value changes (>$50K) to finance approval, but attribute value handling breaks when the field is empty.
Here’s the problematic code:
Double cost = (Double) change.getValue("Estimated_Cost");
if (cost > 50000) {
return "Finance_Approval";
}
This is blocking about 30% of our ECOs from progressing because engineers don’t always populate cost estimates upfront. We need the workflow to handle null values gracefully and route to a default path for review. Has anyone dealt with similar PX conditional logic issues in workflow-mgmt?
Quick fix - add null check before your comparison. But you should also think about what the business logic should be. Does null mean ‘unknown cost’ or ‘no cost impact’? These should route differently. Unknown costs might need estimation before approval, while no-cost changes could skip finance entirely.
I’ve seen this exact issue before. The problem is you’re not doing null checking before the comparison. When Estimated_Cost is null, the unboxing from Double to primitive fails. You need defensive coding in your PX to handle missing attribute values before evaluating conditions.
This is a common pattern we had to fix across multiple workflows. The workflow step execution expects the PX to always return a valid path. When you get a NullPointerException, the workflow engine doesn’t know which transition to follow, so it just stops. Your conditional logic needs to account for three scenarios: null values, zero values, and actual cost data. We implemented a tiered approach where missing cost data routes to a preliminary review step where finance can request the information before the formal approval. This keeps workflows moving instead of blocking them. Also consider setting a workflow variable to flag incomplete cost data so you can track how often this happens and potentially make the field mandatory at an earlier stage.
Here’s a comprehensive solution that addresses all three focus areas - PX conditional logic, attribute value handling, and workflow step execution.
First, fix your immediate null handling issue with proper defensive coding:
Double cost = (Double) change.getValue("Estimated_Cost");
if (cost != null && cost > 50000) {
return "Finance_Approval";
} else if (cost == null) {
return "Cost_Estimation_Required";
}
return "Standard_Approval";
This ensures workflow step execution always gets a valid path. But there’s a better architectural approach:
Attribute Value Handling Strategy:
Implement a three-tier routing logic in your PX:
- Null/Missing Cost: Route to ‘Preliminary_Review’ where cost must be estimated
- High Value (>$50K): Route to ‘Finance_Approval’
- Low Value (≤$50K): Route to ‘Standard_Approval’
Enhanced PX Conditional Logic:
Add validation at the workflow entry point using a Pre-Condition script that checks if critical attributes are populated. This prevents ECOs from even entering the workflow without required data:
Object costObj = change.getValue("Estimated_Cost");
boolean assessmentComplete = (Boolean) change.getValue("Cost_Assessment_Complete");
if (costObj == null && !assessmentComplete) {
// Log for tracking
return "Cost_Estimation_Required";
}
Workflow Step Execution Improvements:
- Configure your ‘Cost_Estimation_Required’ path to loop back to the originator with a notification explaining what’s needed
- Set up workflow variables to track how many times an ECO routes through estimation (prevents infinite loops)
- Add a timeout mechanism where if cost isn’t provided within 5 days, it auto-routes to finance for manual handling
Additional Recommendations:
- Make ‘Estimated_Cost’ conditionally required based on change type - if it’s a design change affecting BOM, make it mandatory
- Implement a workflow report to track ECOs blocked by missing cost data - this gives you metrics to justify process changes
- Consider adding a cost range picker (Low/Medium/High) as a minimum requirement if exact costs can’t be determined early
This approach reduced our blocked workflows from 30% to under 5% and gave finance better visibility into cost impacts earlier in the process. The key is treating null values as a legitimate workflow state that needs handling, not an error condition.