How do I add a validation rule?

Validation Rules ensure that data entered by users meets specific standards before a record can be saved. If the condition in the rule is met, Salesforce displays an error message and prevents the save operation.

Step 1: Navigating to Validation Rules

Step 1: Navigating to Validation Rules
  1. Go to Setup > Object Manager.
  2. Select the Object where you want the rule to apply (e.g., Opportunity or Lead).
  3. Click Validation Rules in the left-hand sidebar.
  4. Click New.

Step 2: Configuring the Rule

Every validation rule requires four primary components:

Step 2: Configuring the Rule
  • Rule Name: A unique identifier (use underscores instead of spaces, e.g., Mandatory_Reason_Code).
  • Active Checkbox: Ensure this is checked for the rule to run.
  • Error Condition Formula: This is the logic that triggers the error. The rule “fires” when the formula evaluates to True.
  • Error Message: The text shown to the user explaining why the record didn’t save.

Step 3: Writing the Formula

Use the Insert Field and Insert Operator buttons to build your logic accurately.

Step 3: Writing the Formula

Example: Ensuring a field is not empty

If you want to make a “Reason” field mandatory when a Lead is “Closed – Lost”:

AND( ISPICKVAL(Status, “Closed – Lost”), ISBLANK(Reason__c) )

  • Check Syntax: Always click this button before saving to catch typos or logic errors.

Step 4: Setting the Error Location

You must choose where the error message appears:

  • Top of Page: Best for errors involving multiple fields or general record logic.
  • Field: Places the error directly under a specific field. This is most user-friendly as it highlights exactly what needs to be fixed.

Step 5: Best Practices for Technical Guides

  • The “Rule of True”: Remind users that the formula describes the bad data, not the good data. If the formula is “True,” the user sees an error.
  • Bypass Logic: To prevent the rule from blocking automated system updates or specific administrators, add a bypass:
    • && $Permission.Ignore_Validation_Rules = False
  • Testing: Always advise testing the rule in a Sandbox before activating it in Production to avoid locking users out of their records.
Last Updated 2nd February 2026.

Was this article helpful?

We publish our Knowledge Base to help individuals and businesses resolve common issues across websites, advertising platforms, Salesforce and other digital systems.

We regularly review and update our guides, but the platforms, software and services covered can change without notice. As a result, screenshots, settings, features or recommended processes may differ from those available when an article was last reviewed.

The information provided is general guidance and should not be treated as advice specific to your systems or circumstances. UTDS Optimal Choice cannot accept responsibility for errors, data loss, service disruption or other issues resulting from changes made by following these guides.

If you are unsure about any of the steps, particularly where a change could affect live systems, data, tracking or business processes, we recommend speaking to us before making the change. Our team can review your specific setup and provide advice based on the current platform and configuration.

Time for some professional support?

Our team area ready to help. As one of the few digital agencies that is a registered Salesforce Consulting Partner and Google Partner Agency, UTDS Optimal Choice is expertly positioned to support you across your entire digital landscape.