Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

Bypass Your Validation Rules

Learning Objectives

After completing this unit, you’ll be able to:

  • Implement bypass switches in your validation rules.

At some point, you’ll probably encounter a situation where you need to update data, but are blocked by validation rules. Or you might have certain users that you want to be exempt from specific validation rules. Enter the bypass switch. In this unit, you learn how to give users permission to bypass one or more validation rules.

Bypassing Validation Rules

A carefully designed validation rule might rarely need a bypass. Let’s say you’ve implemented ISCHANGED and ISNEW in your formulas. Your validation rules should only fire when data is changed to no longer meet your requirements. Typically, bypassing validation rules may be needed to correct historical data or perform data loads. 

Note

If you change data, other users might have trouble editing those records later.

Ready to build a validation rule that has a bypass? Let’s create a validation rule that prevents users from clearing the product interest field on a Lead once it has been populated. You also want to let specific users clear the field. In the steps below, you create a custom permission, assign that permission to a permission set, assign that permission set to a user, and finally create a validation rule that only evaluates to true when a user doesn’t have that permission. That may have sounded like a mouthful, but let’s take it step by step.

Create a Custom Permission

If you need to bypass a validation rule, the first step is to create a custom permission.

  1. In Setup Quick Find, enter Custom Permissions.
  2. Click Custom Permissions.
  3. Click New.
  4. Fill in the following information:
    1. Label: Bypass Lead Validation Rules
    2. Name: Bypass_Lead_Validation_Rules
    3. Description: Allows users to bypass lead validation rules.
  1. Click Save.

Create a Permission Set

Now that you have a custom permission, you need to assign it to a permission set and assign the permission set to a user.

  1. In Setup Quick Find, enter Permission Sets.
  2. Click Permission Sets.
  3. Click New.
  4. Fill in the following information:
    1. Label: Bypass Lead Validation Rules
    2. Name: Bypass_Lead_Validation_Rules
    3. Description: Allows users to bypass lead validation rules.
    4. License: None
  1. Click Save.
  2. On the Permission Set Overview screen, scroll down until you see Custom Permissions.
  3. Click Custom Permissions.
  4. Click Edit.
  5. Add the Bypass Lead Validation Rules Custom Permission to the Enabled Custom Permissions section.
  6. Click Save.
  7. Click Manage Assignments.
  8. Click Add Assignment.
  9. Check the box next to your name.
  10. Click Next.
  11. Click Assign.
  12. Click Done.

Tip: You could use a Session-Based Permission Set and build a Flow that lets users choose when to apply that Permission Set to their current session. This ensures that all users must adhere to validation rules by default. When they encounter a situation that truly requires a bypass, they can access your flow to give them the super powers to save the record. Learn more about this topic in the Session-Based Permission Sets and Security module on Trailhead.

Create a Validation Rule with Bypass

Next, you create a validation rule on Lead that prevents users from clearing the Product Interest field once it is populated.

  1. From Setup, click Object Manager.
  2. Click Lead.
  3. In the left sidebar, click Validation Rules.
  4. Click New.
  5. Enter the following properties for your validation rule:
    1. Rule Name: LEAD002_Product_Interest_Required
    2. Description: Once Product Interest has been populated, it cannot be cleared.
    3. Error Condition Formula:
AND(
  NOT( $Permission.Bypass_Lead_Validation_Rules ),
  NOT(ISBLANK(TEXT( PRIORVALUE( ProductInterest__c )))),
  ISBLANK( TEXT( ProductInterest__c ))
)

d. Error Message: Once Product Interest has been populated, it cannot be cleared [LEAD002]

e. Error Location: Field, Product Interest

6. Click Save.

Let's break down the validation rule formula step by step.

  1. NOT( $Permission.Bypass_Lead_Validation_Rules ): This condition checks if the user does not have the permission to bypass lead validation rules. If the user lacks this specific permission, the formula evaluates to true.
  2. NOT(ISBLANK(TEXT(PRIORVALUE(ProductInterest__c)))): This part of the formula verifies if the previous value of the ProductInterest__c field (before the current edit) is not blank. Because ProductInterest__c is a picklist, we have to use the TEXT function to be able to check if it is blank. If the previous value is not empty, the formula evaluates to true.
  3. ISBLANK(TEXT(ProductInterest__c)): Finally, this part checks if the current value of the ProductInterest__c field is blank. If the field is indeed empty, the formula evaluates to true.

Now, let's put it all together.

The entire formula, with the AND operator wrapping the three conditions, evaluates to true only when all the conditions are met simultaneously.

  • The user does not have the Bypass_Lead_Validation_Rules permission.
  • The previous value of the ProductInterest__c field is not blank.
  • The current value of the ProductInterest__c field is blank.

If all three conditions are satisfied (that is, the formula evaluates to true), the validation rule triggers, and the user will see an error message, preventing them from saving the record until the specified conditions are met. This validation rule helps ensure that when a ProductInterest__c value is changed from a non-blank value to a blank value, users must have the appropriate permission to bypass this validation or provide a new non-blank value for ProductInterest__c.

Resources

Salesforce ヘルプで Trailhead のフィードバックを共有してください。

Trailhead についての感想をお聞かせください。[Salesforce ヘルプ] サイトから新しいフィードバックフォームにいつでもアクセスできるようになりました。

詳細はこちら フィードバックの共有に進む