Question

Difficulty: MediumValidation Rules and Data Quality Enforcement

Match each business requirement for data quality enforcement with the Salesforce validation rule formula that correctly implements the logic.

  • Prevent changes to a custom Discount Percent field after an Opportunity has been closed.AND( ISCHANGED( Discount_Percent__c ), PRIORVALUE( IsClosed ) = TRUE )
  • Require a Justification Note only when a Case's Status picklist is changed to 'On Hold'.AND( ISCHANGED( Status ), ISPICKVAL( Status, "On Hold" ), ISBLANK( Justification_Note__c ) )
  • Enforce that a custom Tax Identification Number field strictly follows a format of two letters followed by seven digits.NOT( REGEX( Tax_ID__c, "[A-Za-z]{2}[0-9]{7}" ) )
  • Prevent users from selecting a past date in the Target Close Date field upon initial record creation.AND( ISNEW(), Target_Close_Date__c < TODAY() )

Answer

1. Preventing edits to Discount Percent on closed opportunities corresponds to using AND( ISCHANGED( Discount_Percent__c ), PRIORVALUE( IsClosed ) = TRUE ).
2. Requiring a Justification Note when changing Status to 'On Hold' corresponds to AND( ISCHANGED( Status ), ISPICKVAL( Status, 'On Hold' ), ISBLANK( Justification_Note__c ) ).
3. Validating Tax Identification Number format corresponds to NOT( REGEX( Tax_ID__c, '[A-Za-z]{2}[0-9]{7}' ) ).
4. Restricting past dates on creation corresponds to AND( ISNEW(), Target_Close_Date__c < TODAY() ).
Each validation rule formula accurately captures the required context: PRIORVALUE detects state prior to save for record lock scenarios, ISCHANGED combined with ISPICKVAL and ISBLANK handles picklist-driven conditional requirements, NOT(REGEX(...)) fires validation errors on non-conforming text patterns, and ISNEW restricts date checks to record insertion.

Step-by-Step Solution

1
Analyze the first requirement regarding locking a field after record closure.
Identified that checking prior field state requires PRIORVALUE() alongside ISCHANGED().
Validation rules evaluate to TRUE to display an error; checking PRIORVALUE(IsClosed) = TRUE detects if the record was already closed prior to the edit.
2
Analyze the second requirement for conditional field population on status change.
Combined ISCHANGED(), ISPICKVAL(), and ISBLANK() within an AND() statement.
Validation errors trigger when all conditions in AND() are met: status changed, new status is 'On Hold', and note is blank.
3
Analyze the third requirement for pattern/format validation.
Selected the regular expression matching function REGEX() inverted with NOT().
REGEX returns TRUE when text matches the pattern. Negating it with NOT() ensures an error is raised when data does NOT conform to the required pattern.
4
Analyze the fourth requirement for record creation date validation.
Paired ISNEW() with date comparison operator against TODAY().
ISNEW() evaluates to TRUE only during insertion, preventing existing historical records with past dates from triggering validation errors during later edits.

Key Concept

Validation Rule Formula Functions (PRIORVALUE, ISCHANGED, REGEX, ISNEW, ISBLANK)
Estimated Time:2m 0s
Rate this question