Partner portal account object Groovy validation fails on custom field with NullPointerException

We’ve added a custom field called PartnerTier to the account object in our partner portal (OCX 23C) using Application Composer. The field is a dropdown with values: Gold, Silver, Bronze. We wrote a Groovy validation script to enforce that certain account types must have specific tier values.

The validation script looks like this:

if (AccountType == 'Strategic Partner') {
  return PartnerTier == 'Gold'
}
return true

When partners try to create new accounts through the portal, they’re getting a NullPointerException error and the record creation fails. The error happens even when they select a tier value. We’ve checked the field mapping and PartnerTier is exposed to the partner portal role.

I think the issue is related to null safety in our Groovy script validation, but I’m not sure how to properly handle custom field values in Application Composer scripts. Has anyone dealt with similar validation failures on custom fields?

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:

  1. Store field values in local variables first
  2. Use the safe navigation operator (?.) to handle nulls
  3. 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:

  1. Always use safe navigation: field?.method() instead of `field.method()
  2. Provide default values: `def tier = PartnerTier ?: ‘Bronze’
  3. Check null explicitly for required validations:
if (PartnerTier == null) {
  return false  // Reject if tier not set
}

Additional Considerations for Your Scenario:

  1. 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.

  2. 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
  1. 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
  2. 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.

Classic null reference error. Your script is trying to compare values before they’re actually set in the object context. During record creation, custom fields might be null even if the user selected a value in the UI. You need null checks.

The problem is definitely your null handling. In Application Composer Groovy scripts, you can’t directly compare null values with == operator without checking first. When a new account is being created, PartnerTier might be null during certain validation phases even if it has a value in the UI form.

You need to add explicit null checks before any comparisons. Also, make sure you’re using the correct field reference syntax - it should be accessing the field from the proper context object.

That makes sense. Should I be using newValue or some other context variable to access the custom field? The Application Composer documentation isn’t very clear about the proper syntax for custom field handling in validation scripts.

In Application Composer validation scripts, you access custom fields directly by their API name, but you need to handle nulls properly. Also be aware that during different phases of record processing (before insert, before update), fields may have different states. For partner portal specifically, there can be timing issues with when field values are populated versus when validations run.

I’d also check your field-level security settings. Even though PartnerTier is exposed to the partner portal role, the validation script runs in a system context that might not have the same visibility. Make sure the field is marked as ‘Enabled for Validation’ in Application Composer field properties. This is a common gotcha that causes null references.

Another thing - dropdown custom fields in Application Composer sometimes have issues with value comparison. Instead of comparing the display value (‘Gold’), you might need to compare the internal code value. Check your field definition to see if there’s a separate code and display value configured.