---
url: https://trigger.beyondthecloud.dev/after-delete/add-ons/bypassable.md
description: >-
  Skip an after delete Writer or Dispatcher for a chunk when a condition holds,
  for example during a batch purge or a data migration.
---

# AfterDelete.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 bypassOnAfterDeleteWhen();
}
```

* `bypassOnAfterDeleteWhen()`: 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 ContactWriter implements AfterDelete.Writer, AfterDelete.Bypassable {
    public static Boolean isBypassed = false;

    public Boolean bypassOnAfterDeleteWhen() {
        return ContactWriter.isBypassed;
    }

    public Boolean writeOnAfterDeleteWhen(TriggerTypes.DeleteRecord record) {
        return record.isNotNull(Contact.AccountId);
    }

    public void writeOnAfterDelete(TriggerTypes.DeleteRecord record, TriggerTypes.UnitOfWork unitOfWork) {
        unitOfWork.toInsert(new Task(WhatId = ((Contact) record.getOldSObject()).AccountId, Subject = 'Review contact'));
    }
}
```

:::

## Rules {#rules}

* **To skip single records, use the predicate.** Return false from `writeOnAfterDeleteWhen` or `dispatchOnAfterDeleteWhen`.
* **Static flags last the whole transaction.** Later chunks and nested saves see them too. Reset a flag in a `finally` block.
* **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
Outside the error handling. An exception here is not logged, ContinueOnError does not apply, and the delete fails.
:::
