Question

Difficulty: Very hardValidation Rules and Data Quality Enforcement

An administrator is configuring a validation rule on the Case object to enforce data quality for enterprise support. The requirement states that when a Case with the Record Type 'Priority_Support' is set to a Status of 'Closed', the custom text field `Root_Cause_Code__c` must be populated and adhere to a specific 5-character format (two uppercase letters followed by three digits, e.g., 'RC101'). Additionally, the rule must only evaluate when the record is newly created or when the Status field is explicitly changed to 'Closed', avoiding false triggers on existing closed cases during mass updates. Which validation rule formula correctly enforces these conditions without failing due to improper null handling?

  1. AND( RecordType.DeveloperName = 'Priority_Support', ISPICKVAL(Status, 'Closed'), OR(ISNEW(), ISCHANGED(Status)), OR(ISBLANK(Root_Cause_Code__c), NOT(REGEX(Root_Cause_Code__c, '[A-Z]{2}[0-9]{3}'))) )Answer
  2. B
    AND( RecordType.DeveloperName = 'Priority_Support', ISPICKVAL(Status, 'Closed'), NOT(REGEX(Root_Cause_Code__c, '[A-Z]{2}[0-9]{3}')) )
  3. C
    AND( RecordType.Name = 'Priority_Support', Status = 'Closed', OR(ISNEW(), ISCHANGED(Status)), REGEX(Root_Cause_Code__c, '[A-Z]{2}[0-9]{3}') )
  4. D
    AND( RecordType.DeveloperName = 'Priority_Support', ISPICKVAL(Status, 'Closed'), ISBLANK(Root_Cause_Code__c) )

Answer

The validation rule formula using AND along with RecordType.DeveloperName, ISPICKVAL, ISNEW/ISCHANGED checks, and an OR condition checking ISBLANK alongside NOT(REGEX(...)) is the correct solution.
The correct formula evaluates the Record Type developer name, enforces picklist validation with ISPICKVAL, scopes evaluation to record creation or Status changes, and combines ISBLANK with NOT(REGEX(...)) so that any missing value or non-conforming text triggers the validation error.

Step-by-Step Solution

1
Identify Record Type and Picklist conditions
Ensure `RecordType.DeveloperName = 'Priority_Support'` and `ISPICKVAL(Status, 'Closed')` are evaluated.
DeveloperName is best practice to prevent breakage across environments, and picklist fields in validation formulas require ISPICKVAL.
2
Restrict rule evaluation context
Wrap `OR(ISNEW(), ISCHANGED(Status))` inside the main `AND` statement.
This prevents existing closed records from firing validation errors when unrelated fields are updated.
3
Implement robust null and format checking
Use `OR(ISBLANK(Root_Cause_Code__c), NOT(REGEX(Root_Cause_Code__c, '[A-Z]{2}[0-9]{3}')))`.
A validation rule fires when the formula yields TRUE. Therefore, the rule must evaluate to TRUE if the field is either blank or does not match the regex pattern.

Key Concept

Validation Rule Logic and Null Handling in Salesforce Formulas
Rate this question