SaasGuru Logo

Kickstart your career with the World's First Salesforce & AI Programs by an IIT - Explore Courses 🎉

Kickstart your career with the World's First Salesforce & AI Programs by an IIT - Explore Courses 🎉
How To Bypass Validation Rule in Salesforce

How To Bypass Validation Rule in Salesforce

Validation rules in Salesforce are essential tools that play a pivotal role in maintaining the integrity and quality of data within the CRM system. These rules are designed to ensure that data input into Salesforce adheres to certain quality standards and requirements.

However, there are instances where flexibility is needed, and certain rules must be bypassed. This blog explores the details of getting around validation rules in Salesforce, providing a thorough guide on how to navigate this process successfully.

From this blog, you’ll gain insights into:

  • Learn what it means to bypass validation rules and why it’s sometimes necessary.
  • Step-by-step guidance on setting up custom permissions to bypass validation rules.
  • Instructions on how to create and allocate permission sets to particular users.
  • Detailed walkthrough on creating validation rules that include a bypass option.

Let’s get started!

What is Bypassing Validation Rules?

Bypassing validation rules refers to the process of allowing certain users or under specific conditions to override these rules. This capability is essential for situations like updating historical data or performing bulk data loads, where strict adherence to validation rules might hinder necessary operations.

Online Bootcamps India

Business Problem:

In this scenario, the challenge arises from the necessity to restrict users from clearing the product interest form on a Lead once it has been populated.

Solution

Creating a Custom Permission for Bypassing Validation Rules in Salesforce

To effectively manage data validation in Salesforce, there may be scenarios where certain users need the ability to bypass validation rules. This can be fulfilled by establishing a custom permission. Here’s how you can set it up:

  1. Navigate to Custom Permissions: In your Salesforce setup, use the Quick Find box to search for “Custom Permissions”. Click on the ‘Custom Permissions’ link.
  2. Create a New Custom Permission: Click the ‘New’ button to create a new custom permission.
  3. Configure the Custom Permission:
  • Label: Enter a descriptive label, such as “Bypass Lead Validation Rules”.
  • Name: Choose a distinct name, such as “Bypass_Lead_Validation_Rules”. 
  • Description: Give a concise explanation, like “Enables users to bypass lead validation rules”. 
  • To complete the custom permission, click ‘Save’.

Setting Up a Permission Set

After creating the custom permission, the next step is to assign it to a permission set and then to the relevant users.

1. Access Permission Sets: In the Setup area, use the Quick Find box to search for “Permission Sets”. Click on ‘Permission Sets’.

2. Create a New Permission Set: Click the ‘New’ button and fill in the details:

  • Label: “Bypass Lead Validation Rules”. 
  • Name: “Bypass_Lead_Validation_Rules”. 
  • Description: “Permits users to bypass lead validation rules”.
  • License: Choose ‘None’.
  • Click ‘Save’.

3. Assign Custom Permission to the Set:

  • On the Permission Set Overview page, find ‘Custom Permissions’ and click on it.
  • Click ‘Edit’ and add the “Bypass Lead Validation Rules” custom permission to the ‘Enabled Custom Permissions’ section.
  • Click ‘Save’.

4. Assign Permission Set to Users:

  • Click ‘Manage Assignments’.
  • Click ‘Add Assignment’.
  • Select the checkbox next to the names of users who need this permission.
  • Click ‘Next’, then ‘Assign’, and finally ‘Done’.

Note: For more dynamic control, consider using a Session-Based Permission Set. This allows users to activate the permission when needed, ensuring that validation rules are bypassed only under specific circumstances. 

You can create a Salesforce Flow to enable users to apply this permission set to their current session, maintaining the integrity of your data validation process.

Also Read – Salesforce Order of Execution: A Complete Guide

Creating a Bypassable Validation Rule in Salesforce

We’ll delve into how to create a validation rule in a Lead object that stops users from erasing the ‘Product Interest’ field after it’s filled yet permits certain users to bypass this rule.

Steps to Create a Bypassable Validation Rule

1. Navigate to the Lead Object:

  • Go to Setup and click on Object Manager.
  • Select the Lead object.

2. Access Validation Rules:

In the Lead object menu, find and click on ‘Validation Rules’.

3. Create a New Validation Rule:

Click ‘New’ to start creating a new validation rule.

4. Define the Validation Rule:

  • Set the Rule Name as ‘LEAD002_Product_Interest_Required’.
  • Add a Description: “Prevents clearing the Product Interest field once populated, except for authorized users.”
  • Set the Error Condition Formula:

AND(

  NOT( $Permission.Bypass_Lead_Validation_Rules ),

  NOT(ISBLANK(TEXT( PRIORVALUE( ProductInterest__c )))),

  ISBLANK( TEXT( ProductInterest__c ))

)

  • Set the Error Message to: “Product Interest cannot be cleared once set [LEAD002]”.
  • Choose the Error Location as the ‘Product Interest’ field.

5. Save the Validation Rule: 

Click ‘Save’ to activate the rule.

Understanding the Validation Rule Formula

  • NOT( $Permission.Bypass_Lead_Validation_Rules ): This checks if the user does not have the bypass permission. If they don’t, this part of the formula returns true.
  • NOT(ISBLANK(TEXT(PRIORVALUE(ProductInterest__c)))): This checks if the ‘Product Interest’ field was not empty before the current edit.
  • ISBLANK(TEXT(ProductInterest__c)): This checks if the ‘Product Interest’ field is currently empty.

The rule uses the AND function to ensure all conditions are met for the rule to apply. If a user without the bypass permission tries to clear a previously set ‘Product Interest’ field, the rule prevents saving the record and displays the error message.

saasguru Salesforce Labs: Real-time Projects for Practice

Summing Up

Understanding how to bypass validation rules in Salesforce is a valuable skill that enhances flexibility and efficiency in data management. By creating custom permissions and setting up permission sets, Salesforce administrators can ensure that data integrity is maintained while providing necessary exceptions for specific scenarios. The ability to craft bypassable validation rules empowers teams to handle unique data entry situations without compromising the overall data quality.

If you want to enhance your Salesforce skills, consider joining our Slack community. In this community, you’ll engage with Salesforce enthusiasts and professionals, exchange ideas, and keep abreast of the newest trends and effective practices. 

Moreover, saasguru offers interactive training and real-time projects in online Salesforce bootcamps. These bootcamps are structured to deliver hands-on learning and comprehensive understanding, equipping you for success in your Salesforce career. 

Join us at saasguru and take your Salesforce skills to the next level!

Table of Contents

Subscribe & Get Closer to Your Salesforce Dream Career!

Get tips from accomplished Salesforce professionals delivered directly to your inbox.

Looking for Career Upgrade?

Book a free counselling session with our Course Advisor.

By providing your contact details, you agree to our Terms of use & Privacy Policy

Unlock Your AI -Powered Assistant

Gain Exclusive Access to Your Salesforce Copilot

Related Articles

Top Courses for Working Professionals in IIT

Access top IIT online courses for professionals. Enhance skills in AI, data science, and management from IIT Delhi, Bombay, Kanpur & more.

IIT Kanpur Certificate Courses 2025

Explore IIT Kanpur’s top certifications in Salesforce, Data Science, AI & more. Boost your career with industry-ready skills. Read now!

How Slack Became a Top-Ranked Collaboration Tool by IDC MarketScape

Discover why Slack is a Leader in team collaboration, recognized by IDC MarketScape for its advanced, AI-powered workspace features.