Courseiva

SF-PD2 Advanced Developer Fundamentals Practice Question

A developer needs to enforce that a custom object's field is required only when another field has a specific value. The validation must apply to all data entry points, including API and Apex. Which feature should be used?

⚠ Common exam trap

The trap here is assuming that page layout or field-level required settings are enforced universally, when they are limited to specific interfaces.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

A validation rule with a formula that checks the condition.

A validation rule is the correct choice because it is enforced at the database level for all data operations, regardless of the entry point. It uses a formula to conditionally require a field based on another field's value, ensuring data consistency. Other options either do not cover all entry points or cannot express conditional logic.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    A page layout setting that marks the field as required.

    Why it's wrong here

    Page layout required fields only apply when users edit records through the Salesforce user interface. They do not enforce the requirement for API calls, Apex, or other data loading tools. This would not satisfy the need for enforcement across all data entry points, leaving gaps in data integrity.

  • ✗

    A field-level security setting that makes the field required.

    Why it's wrong here

    Field-level security controls access to fields but does not enforce conditional requiredness. Making a field required at the field definition level applies universally, not conditionally. Field-level security cannot express a condition based on another field's value, so it cannot meet the requirement.

  • ✗

    Apex trigger with a before insert/update logic to check the condition.

    Why it's wrong here

    While an Apex trigger can enforce the condition, it only applies to operations that go through Apex. Data loaded via API or other tools that bypass Apex would not be validated. Triggers also require code maintenance and can be bypassed if not carefully designed. Validation rules are more robust for this requirement.

  • ✓

    A validation rule with a formula that checks the condition.

    Why this is correct

    Validation rules are enforced at the database level for all data entry points, including API, Apex, and user interface. A formula can check if the dependent field has the specific value and if the required field is blank, then display an error. This ensures consistent enforcement across all channels without additional code.

About these practice questions

This SF-PD2 question is part of Courseiva's 226-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Salesforce exam blueprint

This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.