Question

Difficulty: Very hardValidation Rules and Data Quality Enforcement

Universal Containers implemented a validation rule on the Opportunity object to enforce data quality. The goal is to require a custom field, Discount_Approval_Code__c, whenever Discount_Percentage__c is updated to a value greater than 15% (0.15). However, administrators notice that when users update unrelated fields (such as Description) on existing records where Discount_Percentage__c was already set to 20% in the past, the system blocks the save and displays a validation error.

The current validation rule formula is:
AND(Discount_Percentage__c > 0.15, ISBLANK(Discount_Approval_Code__c))

Which formula modification correctly prevents the validation error from triggering during edits to unrelated fields while still enforcing the requirement when the discount is modified?

  1. AND(Discount_Percentage__c > 0.15, ISCHANGED(Discount_Percentage__c), ISBLANK(Discount_Approval_Code__c))Answer
  2. B
    AND(Discount_Percentage__c > 0.15, NOT(ISBLANK(Discount_Percentage__c)), ISBLANK(Discount_Approval_Code__c))
  3. C
    AND(PRIORVALUE(Discount_Percentage__c) > 0.15, ISBLANK(Discount_Approval_Code__c))
  4. D
    AND(ISPICKVAL(StageName, "Closed Won"), Discount_Percentage__c > 0.15, ISBLANK(Discount_Approval_Code__c))

Answer

AND(Discount_Percentage__c > 0.15, ISCHANGED(Discount_Percentage__c), ISBLANK(Discount_Approval_Code__c))
The formula combining Discount_Percentage__c > 0.15, ISCHANGED(Discount_Percentage__c), and ISBLANK(Discount_Approval_Code__c) ensures the validation rule triggers only when the discount percentage field itself is modified in the transaction. When an administrator or user edits an unrelated field like Description on an existing record with a high discount, ISCHANGED evaluates to FALSE and the save completes successfully without requiring an approval code.

Step-by-Step Solution

1
Identify why the validation rule triggers on unrelated field updates.
The current formula checks if Discount_Percentage__c > 0.15 on every save operation regardless of whether Discount_Percentage__c was modified in that transaction.
Validation rule formulas run their full boolean evaluation whenever any editable field on the record is saved.
2
Determine the Salesforce formula function that checks whether a specific field's value has changed during the edit.
The ISCHANGED() function returns TRUE only if the current value differs from the prior value in the current context.
ISCHANGED restricts rule execution specifically to edits where the target field has been updated.
3
Combine conditions to form the updated validation rule formula.
AND(Discount_Percentage__c > 0.15, ISCHANGED(Discount_Percentage__c), ISBLANK(Discount_Approval_Code__c))
This formula successfully verifies that the discount exceeds 15%, that the discount field was modified in this save, and that the approval code is blank.

Key Concept

Using ISCHANGED() in Salesforce validation rules to prevent false positives when editing unrelated record fields
Rate this question