Bypassing Automations and Validations in Salesforce

By in
649
Bypassing Automations and Validations in Salesforce

Sometimes it’s important for an Administrator to have master access to things a normal user can’t do, such as bypassing systems automations or validations. This is especially necessary when it comes to data manipulation.

 

How to Bypass Automations and Validations

To bypass automations and validations, we first need to create a custom setting with the following fields:

  1. User (Lookup)
  2. Master Access (Checkbox)

 

Validation Rules

When you are creating any validation rule and you want to make sure that a particular set of Users can bypass that rule, you can write the following condition in the validation rule.

Condition -> IF($Setup.your_custom_setting.Master_Access, do_nothing, other condition for validation rule)

 

Apex Code

Master_Access__c masterAccess = Master_Access__c.getInstance(UserInfo.getProfileId());

if(!masterAccess.Master_Access && other_conditions) {

//do something

}

 

Conclusion

You can easily make sure that some of your users have master access to the system by using Validation Rules or Apex Code. This is to make sure that you have a fail-safe in case any automation has messed up your data in production.

Continue learning about Salesforce access and security with, “Salesforce Record Security.”

Additional Resources

Cover Photo by Christopher Beddies on Unsplash

Leave a reply

Your email address will not be published. Required fields are marked *