---
url: https://trigger.beyondthecloud.dev/before-update/add-ons/bypassable.md
description: >-
  Skip a before update Populator or Validator when a condition holds, such as a
  static flag or a custom permission.
---

# BeforeUpdate.Bypassable

Skip a handler for the whole chunk when a condition holds, such as a static flag, a batch job or a custom permission.

**Signature**

```apex
public interface Bypassable {
    Boolean bypassOnBeforeUpdateWhen();
}
```

* `bypassOnBeforeUpdateWhen()`: called once per chunk, before parents load. Returns `true` to skip this handler for this chunk.

**Example**

::: code-group

```apex [Skeleton]
public with sharing class ContactPopulator implements BeforeUpdate.Populator, BeforeUpdate.Bypassable {
    public static Boolean isBypassed = false;

    public Boolean bypassOnBeforeUpdateWhen() {
        return ContactPopulator.isBypassed;
    }

    public Boolean populateOnBeforeUpdateWhen(TriggerTypes.UpdateRecord record) {
        return record.isChanged(Contact.Email);
    }

    public void populateOnBeforeUpdate(TriggerTypes.UpdateRecord record) {
        record.put(Contact.HasOptedOutOfEmail, false);
    }
}
```

```cls \[Static flag]
public with sharing class OpportunityReopenValidator implements BeforeUpdate.Validator, BeforeUpdate.Bypassable {
    public static Boolean isBypassed = false;

    public Boolean bypassOnBeforeUpdateWhen() {
        return OpportunityReopenValidator.isBypassed;
    }

    public Boolean addErrorOnBeforeUpdateWhen(TriggerTypes.UpdateRecord record) {
        return record.isChangedFrom(Opportunity.StageName, 'Closed Won');
    }

    public void addErrorOnBeforeUpdate(TriggerTypes.RejectableUpdateRecord record) {
        Opportunity newOpportunity = (Opportunity) record.getNewSObject();

        record.addError(
            Opportunity.StageName,
            'A Closed Won Opportunity cannot be moved back to ' + newOpportunity.StageName + '. Raise a new Opportunity for the follow-up business.'
        );
    }
}

```

:::

## Rules {#rules}

* **To skip single records, return false from the predicate.**
* **Reset a static flag in `finally`.** The flag stays set for every chunk and every nested update in the transaction.
* **Only this context.** [Apex bypasses](/guide/bypasses#apex) cover every context, and `bypass().handler(X.class)` never matches an inner class. A [`TriggerHandler__mdt`](/api/custom-metadata#trigger-handler) record covers the one context it names, for every user.

::: warning
Exceptions here are not logged. `bypassOnBeforeUpdateWhen()` runs outside the handler's error handling. ContinueOnError does not apply, and the update fails.
:::
