# How do you implement a Trigger Bypass mechanism using Custom Metadata Types or Hierarchy Custom Settings?

**Topic:** Apex Trigger · **Difficulty:** Medium · **Asked at:** PwC, EY, Slalom, KPMG · **Tags:** apex-trigger, trigger, bypass, custom-metadata

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-you-implement-a-trigger-bypass-mechanism-using-custom-metadata-types-or-hierarchy-custom-settings

## Answer

Create a config record with a checkbox such as `Bypass_Account_Trigger__c`, and check it at the start of the trigger/handler.

- **Hierarchy Custom Setting:** value can be set per org, profile or user (e.g. bypass for the integration user or during data loads), editable without deployment, and `getInstance()` doesn't use SOQL.
- **Custom Metadata Type:** deployable with metadata, good for permanent switches, but not changeable via DML in the same transaction.
- **Custom Permission:** `FeatureManagement.checkPermission()` for per-user bypass.

```apex
Trigger_Settings__c s = Trigger_Settings__c.getInstance();
if (s.Bypass_Account_Trigger__c) return;
```
Also provide a static in-code bypass for tests and for avoiding recursion.

---
Source: ForceChallenges · last updated 2026-10-21
