Home SALESFORCE ByPass Salesforce Validation Rules Using Hierarchy Custom Settings

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.

You may also like

Leave a Comment