Question

Difficulty: MediumValidation Rules and Data Quality Enforcement

A Salesforce administrator needs to enforce data quality standards on the Opportunity object. Management requires that whenever an Opportunity stage is set to 'Closed Won', the custom text field Contract_Number__c must not be left empty. Which validation rule formula should the administrator implement to meet this requirement?

  1. AND(ISPICKVAL(StageName, "Closed Won"), ISBLANK(Contract_Number__c))Answer
  2. B
    AND(StageName = "Closed Won", Contract_Number__c = NULL)
  3. C
    AND(ISPICKVAL(LeadSource, "Closed Won"), ISBLANK(Contract_Number__c))
  4. D
    AND(ISPICKVAL(RecordType.Name, "Closed Won"), ISBLANK(Contract_Number__c))

Answer

AND(ISPICKVAL(StageName, "Closed Won"), ISBLANK(Contract_Number__c))
The formula correctly uses ISPICKVAL to evaluate the picklist field StageName and ISBLANK to verify whether the custom text field Contract_Number__c contains no value. In Salesforce, validation rules trigger when the formula evaluates to true, so requiring a field to be populated when a picklist matches a specific value is expressed by combining the picklist match and the blank check within an AND statement.

Step-by-Step Solution

1
Identify the picklist field and proper evaluation function
StageName is a picklist field, requiring ISPICKVAL(StageName, "Closed Won") to evaluate its selected value.
Direct text comparison operator '=' is not valid for picklist fields in standard Salesforce formulas without using TEXT().
2
Identify the text field null/blank check function
ISBLANK(Contract_Number__c) returns true when the text field is empty.
ISBLANK is the standard function for evaluating empty text and custom fields in Salesforce validation rules.
3
Combine both conditions into an AND logical block
AND(ISPICKVAL(StageName, "Closed Won"), ISBLANK(Contract_Number__c)) triggers the error message when both conditions evaluate to true.
A validation rule prevents record save when its formula evaluates to true.

Key Concept

Validation Rule Picklist and Null Handling Functions
Rate this question