Custom validation API for part approval throws unexpected null reference error during rule execution in validation management

I’ve implemented a custom server-side validation method for our automated part approval workflow in Aras 12.0, but it’s throwing NullPointerException when processing certain parts. The validation runs during the approval workflow and checks custom properties before allowing progression.

The error occurs intermittently, specifically when the validation API attempts to access part properties:

String materialType = part.getProperty("material_type");
if (materialType.equals("METAL")) {
    // validation logic
}

Error trace shows:


NullPointerException at CustomValidator.validate(line 47)
at ApprovalWorkflow.executeValidation(line 203)

The validation works fine for most parts but fails on approximately 15% of submissions, blocking critical approvals. I’ve verified the property exists in the ItemType definition. What’s the proper null-safe approach for accessing properties in IOM validation methods?

Check your workflow configuration too. If the validation is triggered before mandatory fields are populated, you’ll get nulls regardless of your code quality. The timing of when validation executes in the approval lifecycle matters significantly. We moved our validation to a later workflow state and reduced similar errors by 80%.

Beyond the immediate null check fix, consider implementing a validation framework pattern that handles these cases systematically across all your custom methods.

I had the exact same issue in our validation methods last year. The solution involves implementing proper null-safe property access patterns throughout your validation logic. You also need to consider default values and whether empty strings should be treated differently from null values in your business logic.

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.