function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Malli GMalli G 


when we want disable all the validationrules for a specific user on all the sobjects how we can achieve this give me some examples
and how to deactivate the triggers for a specific user
Ray C. KaoRay C. Kao
You can disable the validation rule and trigger by user's information or user's profile.
Here are the working examples and please have fun with them.

User information
  • Name: Test User (Id: 0050000001AabCD)
  • Profile: TestProfile (Profile Id: 00e000000098XYZ)
Example 1 of validation rule (UserId as the criteria)
IF($User.Id='0050000001AabCD',false,...the original validation rule...)
Example 1 of trigger (UserId as the criteria)
Trigger CaseTrigger on Case (before insert){
  for(Case c :{
    if(Userinfo.getUserId()=='0050000001AabCD') return;
    ... original trigger codes ...

Example 2 of validation rule (Profile as the criteria)
IF($User.ProfileId='00e000000098XYZ',false,...the original validation rule...)
Example 2 of trigger (Profile as the criteria)
Trigger CaseTrigger on Case (before insert){
  for(Case c :{
    if(Userinfo.getProfileId()=='00e000000098XYZ') return;
    ... original trigger codes ...
Kofi A. JohnsonKofi A. Johnson
The best way to achieve that is to create a Chexbox on the User Sobject. You will name that Checkbox something like : "Bypass Triggers And Validations". The idea is, every time you want to bypass Triggers and Validations for a specific user, you just need to check that Checkbox on that User record.

Then in all your Validations Rule, add the condition : 
IF($User.BypassTriggerAndValidations, false,... your validation rule here...)

And in your Triggers add this line on top :
// If the byPassTriggers() is true, "return" will be called and then exit the Trigger
if(CurrentUser.byPassTriggers() == true) {
CurrentUser is a class that you need to create, and will look like :
// CurrentUser load the current User, with the field BypassTriggersAndValidations__c, and return it.
public class CurrentUser {
    private static User record;

    public static Boolean byPassTriggers() {
        if(record == null) {
            record = [
                SELECT BypassTriggersAndValidations__c
                FROM User 
                WHERE Id =:UserInfo.getUserId()
        return record[0].BypassTriggersAndValidations__c;

Kofi A. JohnsonKofi A. Johnson
@Malli G did the solution solve your problem ?