The root cause is inadequate null-safe property access in your custom server-side validation method. Here’s a comprehensive solution addressing all three critical aspects:
1. Null-Safe Property Access Pattern
Replace your current property access with proper null checking:
String materialType = part.getProperty("material_type");
if (materialType != null && materialType.equals("METAL")) {
// validation logic
}
Or use the safer approach:
String materialType = part.getProperty("material_type", "");
if ("METAL".equals(materialType)) {
// validation logic
}
The second approach uses equals() on the constant string, which is inherently null-safe. The getProperty() overload with default value ensures you never get null.
2. Automated Approval Workflow Integration
Your validation timing is critical. Ensure validation executes after all required properties are populated:
- Move validation to the “Ready for Approval” workflow state rather than “In Work”
- Add a pre-validation check that verifies mandatory properties exist
- Return clear error messages indicating which properties are missing
3. Comprehensive Validation Framework
Implement a reusable validation utility class:
public class PropertyValidator {
public static String getPropertySafe(Item item, String propName, String defaultValue) {
String value = item.getProperty(propName);
return (value != null && !value.isEmpty()) ? value : defaultValue;
}
}
This approach standardizes property access across all validation methods, preventing similar issues in future customizations. The 15% failure rate you’re seeing likely corresponds to parts created via import or API where optional properties aren’t set, versus manually created parts where the UI enforces field population.
Additionally, enhance your error logging to capture which specific properties are null when validation fails. This helps identify patterns in the problematic 15% of submissions and may reveal data quality issues in upstream systems feeding your PLM.