Question

Difficulty: MediumValidation Rules and Data Quality Enforcement

A Salesforce administrator is implementing data quality controls across various objects in an organization. Match each business requirement with the correct validation rule formula expression designed to enforce that data quality requirement.

  • Prevent users from modifying the Discount Percentage field after an Opportunity has already reached the 'Closed Won' stage.AND(ISPICKVAL(PRIORVALUE(StageName), "Closed Won"), ISCHANGED(Discount_Percentage__c))
  • Enforce that a custom Tax Identification Number field matches a specific format of two uppercase letters followed by six numerical digits whenever it is populated.AND(NOT(ISBLANK(Tax_ID__c)), NOT(REGEX(Tax_ID__c, "[A-Z]{2}[0-9]{6}")))
  • Require the Phone field to be populated whenever a Lead record rating is set to 'Hot'.AND(ISPICKVAL(Rating, "Hot"), ISBLANK(Phone))
  • Prevent a Project Target Completion Date from being set to a date prior to the record's creation date.Target_Completion_Date__c < DATEVALUE(CreatedDate)

Answer

Matching pairings: Preventing modifications to Discount Percentage after Closed Won matches AND(ISPICKVAL(PRIORVALUE(StageName), 'Closed Won'), ISCHANGED(Discount_Percentage__c)); Validating Tax ID format matches AND(NOT(ISBLANK(Tax_ID__c)), NOT(REGEX(Tax_ID__c, '[A-Z]{2}[0-9]{6}'))); Requiring Phone for Hot Leads matches AND(ISPICKVAL(Rating, 'Hot'), ISBLANK(Phone)); Enforcing Target Completion Date after CreatedDate matches Target_Completion_Date__c < DATEVALUE(CreatedDate).
Each validation formula expression correctly models the specific business requirement using Salesforce formula functions: PRIORVALUE and ISCHANGED monitor field edits relative to previous values; REGEX combined with NOT(ISBLANK) validates pattern compliance; ISPICKVAL combined with ISBLANK enforces mandatory inputs; and DATEVALUE normalizes DateTime fields for comparison.

Step-by-Step Solution

1
Analyze requirement 1 (preventing changes after stage completion)
Identified that PRIORVALUE(StageName) checks historical state before edit, and ISCHANGED(Discount_Percentage__c) detects field edits.
Validation rules evaluate to TRUE to block saving; checking PRIORVALUE ensures past stage state is evaluated.
2
Analyze requirement 2 (pattern matching on populated text fields)
Identified REGEX for format matching and NOT(ISBLANK()) to skip blank entries.
Regular expressions allow precise pattern criteria matching such as two uppercase letters followed by six numbers.
3
Analyze requirement 3 (conditionally required fields based on picklist value)
Identified ISPICKVAL for picklist evaluation combined with ISBLANK for detecting null/missing phone values.
Validation rules trigger when formula condition evaluates to TRUE, meaning Rating is 'Hot' AND Phone is blank.
4
Analyze requirement 4 (date field comparison against system creation date)
Identified DATEVALUE function to convert CreatedDate (DateTime) to Date for direct comparison with Target_Completion_Date__c.
Date and DateTime fields cannot be compared directly without type conversion using DATEVALUE.

Key Concept

Salesforce Validation Rule Formula Functions and Data Quality Enforcement
Rate this question