Let me address all three focus areas comprehensively: Groovy script validation, custom field handling, and null safety in Application Composer.
Groovy Script Validation Issues:
Your validation script has multiple problems. In Application Composer, validation scripts execute at different lifecycle points, and field values may not be fully populated during early validation phases. The NullPointerException occurs because you’re attempting string comparison without null safety.
Custom Field Handling:
For custom fields in Application Composer, you need to use proper accessor methods and null-safe operators. Here’s the corrected validation script:
def accountType = AccountType
def partnerTier = PartnerTier
if (accountType?.equals('Strategic Partner')) {
return partnerTier?.equals('Gold')
}
return true
Key changes:
- Store field values in local variables first
- Use the safe navigation operator (?.) to handle nulls
- Use .equals() method instead of == for string comparison
Null Safety in Application Composer:
Application Composer custom fields require explicit null handling because:
- During record creation, fields are null until the transaction commits
- Partner portal submissions may have different field population timing
- Validation scripts run before field values are persisted
Best practices for null safety:
- Always use safe navigation:
field?.method() instead of `field.method()
- Provide default values: `def tier = PartnerTier ?: ‘Bronze’
- Check null explicitly for required validations:
if (PartnerTier == null) {
return false // Reject if tier not set
}
Additional Considerations for Your Scenario:
-
Field API Names: Verify you’re using the correct API name for PartnerTier. In Application Composer, go to the field definition and check the ‘Name’ field (not ‘Display Label’). Custom fields typically have a suffix like _c.
-
Validation Timing: If you need to validate only on update (not creation), add a condition:
if (Id == null) return true // Skip validation for new records
-
Partner Portal Context: Partner portal users have restricted field visibility. Ensure:
- PartnerTier has ‘Visible’ and ‘Updateable’ enabled for Partner role
- The field is included in the partner portal page layout
- Field-level security grants read access to the validation context
-
Better Error Messaging: Instead of returning false, provide meaningful error messages:
if (AccountType?.equals('Strategic Partner') && !PartnerTier?.equals('Gold')) {
adf.error.raise('CUSTOM_VALIDATION_ERROR',
'Strategic Partners must be assigned Gold tier')
return false
}
return true
Complete Robust Solution:
// Null-safe validation for Partner Tier based on Account Type
def accountType = AccountType
def partnerTier = PartnerTier
// Skip validation if this is a new record and tier not yet set
if (Id == null && partnerTier == null) {
return true
}
// Validate Strategic Partners must be Gold tier
if (accountType?.equals('Strategic Partner')) {
if (partnerTier == null || !partnerTier.equals('Gold')) {
adf.error.raise('TIER_MISMATCH',
'Strategic Partner accounts require Gold tier assignment')
return false
}
}
return true
This approach handles all null scenarios, provides clear error messages, and works correctly in both partner portal and standard UI contexts. Test thoroughly in sandbox with both creation and update scenarios to ensure the validation behaves as expected.
This draft is based on general Oracle CX Cloud knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.