Don’t get triggered!
As an admin you need not only to control your emotions but also your triggers. Sometimes both will overwhelm you and you need shut one of them down. Let’s start with the easier one: Your apex triggers!
While apex Triggers have an active/inactive checkbox on sandbox you don’t have that luxury feature on production.

There are two ways you can deactivate a trigger on production:
Option 1:
- Go to sandbox
- Set ‘is active’ to false
- Redeploy your trigger
Option 2:
- Create medata data type for triggers
- Give it a checkbox to control active/inactive
- Make it a criteria in the trigger
- Switch you trigger on and off using the metadata in production
This is what the meta data looks like:
- Create Custom Medata Type and call it ‘Trigger Control’
- Create two fields
- Trigger_Name__c
- Is_Active__c
- Create a record in you metadata for each trigger you want to control
- Trigger_Name__c holds the name of your trigger
- Is_Active__c is either true or false depending on what you need

Using Meta Data in Example Trigger:
trigger AccountTrigger on Account (before insert, before update) {
Trigger_Control__mdt control = [
SELECT Is_Active__c
FROM Trigger_Control__mdt
WHERE DeveloperName = 'AccountTrigger'
LIMIT 1
];
if (!control.Is_Active__c) {
return; // Trigger is deactivated via metadata
}
// Trigger logic goes here
}
Code language: JavaScript (javascript)
Leave a Reply