ByPass Salesforce Validation Rules Using Hierarchy Custom Settings

It is easy to bypass a Validation Rule for a single user or a profile – in such a case,
here for example to bypass a validation rule in a system administrator, please use the below validation rule formula:

AND (
    ISBLANK(EMAIL),
    ISBLANK(PHONE),
    $Profile.Name <> 'System Administrator'
)

Otherwise, this is achievable from Custom Settings with Hierarcy Type.
Custom Settings are available to both Workflows and Triggers. If we create a “Hierarchy” type custom setting object with a checkbox you can reference that checkbox to enable/disable the validation or code.

The hierarchy design to allow you to set system wide defaults and then override individual users as needed. Its been pretty effective in a number of occasions.

Hierarchy type custom settings gives a flexbilty to have options for specific users.
we can create 2 checkbox of custom setting to Disable Validation Rule, Disable Workflow Rule, Disable Trigger and use the custom settings to Validation Rule/Workflow Rule/Triggers.

For the below video, explained to ByPass validation rule to Profile and User level with Live Example using Hierarchy Custom Settings.

Use Case – https://success.salesforce.com/answers?id=9063A000000E2g8QAC (If we need to bypass a validation rule based on profiles dynamically. What needs to be done? Do we need to make records (profile name and checkbox ) in custom settings for all profiles and then check the value of all profiles ?)

Important Note:
Also make sure, while deploying the changes from dev/sandbox to production, you need to move the data seperately using dataloader or to create data manually after the deployment of custom settings and validation rule.

Because these are considered to be data, these will not migrate via change set. The data will need to be exported and inserted into Production using Data Loader as a Post Production deployment activities.

(146)

Written by 

I am Sakthivel Madesh, a certified Salesforce Developer & Administrator working on Salesforce Technology since 2011. I am currently working in IBM Austraila as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 12x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply