DATA-ARCHITECT practice question 18 of 35

Universal Containers (UC) has several custom Visualforce applications have been developed in which users are able to edit Opportunity records. UC…

Full set: 257 questions
Universal Containers (UC) has several custom Visualforce applications have been developed in which users are able to edit Opportunity records. UC struggles with data completeness on their Opportunity records and has decided to make certain fields required that have not been in the past. The newly required fields are dependent on the Stage of the Opportunity, such that certain fields are only required once an Opportunity advances to later stages. There are two fields. What is the simplest approach to handle this new requirement?
Answer options
A: Update the Opportunity page layout to mark these fields as required.
B: Use a validation rule for each field that takes the Stage into consideration. Correct answer
C: Update these Opportunity field definitions in Setup to be required.
D: Write an Apex trigger that checks each field when records are saved.
Correct Answer:
B. Use a validation rule for each field that takes the Stage into consideration.
Explanation

The requirement is to make fields required based on a condition—the value of the Opportunity Stage field. This is a classic use case for a validation rule. A validation rule formula can check if the Opportunity Stage has advanced to a certain value and, if so, verify that the dependent fields are not blank. This is the simplest, most direct, and most maintainable declarative approach. It enforces the rule at the data level before a record is saved, regardless of whether the change is made via the UI or API, without requiring any code.

Why Incorrect

A. Update the Opportunity page layout to mark these fields as required. Making a field required on the page layout is not conditional; it applies to all records using that layout, regardless of the Opportunity Stage.
C. Update these Opportunity field definitions in Setup to be required. This makes the field universally required for all records at the database level, which does not meet the conditional requirement.
D. Write an Apex trigger that checks each field when records are saved. While an Apex trigger can accomplish this, it is a code-based solution. A validation rule is a simpler, declarative alternative, and simplicity is a key part of the question.

References

1. Salesforce Help. (n.d.). Validation Rules. "Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record."

2. Salesforce Help. (n.d.). Examples of Validation Rules. The documentation provides numerous examples of conditional logic, such as: "Ensure that users don't change the name of a closed opportunity. AND( ISPICKVAL(PRIORVALUE(StageName), "Closed Won"), StageName PRIORVALUE(StageName) )". This demonstrates the capability to base rules on picklist values like Stage.

3. Salesforce Trailhead. (n.d.). Formulas and Validations Module. "Use validation rules to enforce conditional or complex business rules on your users for data entry." This explicitly calls out conditional enforcement as a primary use case.

Scroll to Top