Loading

Conditionally Make a Field Required in Salesforce

Date de publication: Jul 3, 2026
Description

In Salesforce, you can conditionally make a field required based on the values of other fields by using a Validation Rule. A Validation Rule uses a formula to evaluate record data. If the formula evaluates to TRUE, Salesforce prevents the record from being saved and displays an error message to the user.

This approach is useful when a field should only be required under specific conditions—for example, requiring a field to be completed only when a related picklist field has a particular value. This article provides a sample validation formula and step-by-step instructions for creating a conditional required field validation rule in both Salesforce Classic and Lightning Experience.

Résolution

Example Validation Rule Formula

The following Validation Rule formula can be used as a reference for making a field conditionally required:

 
AND(Account_Market = "Corporate", Test = "")
 

This formula makes the Test field required when the Account_Market field value is "Corporate".

The formula returns TRUE (triggering the validation error and preventing the record from being saved) when both of the following conditions are met:

  • Account_Market equals "Corporate".
  • The Test field is blank.

If either condition is not met, the formula returns FALSE, and the record is saved successfully.

Modify the field API names (Account_Market, Test) and the comparison value ("Corporate") to match your Salesforce object and business requirements.

Create a Validation Rule in Salesforce Classic

  1. Click Setup.
  2. Navigate to Customize | [Object] | Validation Rules.
  3. Click New.
  4. Enter a name for the Validation Rule.
  5. Enter the Validation Formula, modifying the example as needed.
  6. Specify the error message that users should see when the validation rule is triggered.
  7. Click Save.

Create a Validation Rule in Lightning Experience

  1. Click the Gear icon and select Setup.
  2. Navigate to Object Manager | [Object] | Validation Rules.
  3. Click New.
  4. Enter a name for the Validation Rule.
  5. Enter the Validation Formula, modifying the example as needed.
  6. Specify the error message that users should see when the validation rule is triggered.
  7. Click Save.
Numéro d’article de la base de connaissances

000385092

 
Chargement
Salesforce Help | Article