+ Start a Discussion
Mila JohnsonMila Johnson 

Check my trigger.

Hello all,

Need some help on this trigger please. Created a custom setting to bypass user for this trigger.

trigger Deleteaccount on Account (before delete) {
    
        Automation_Processes__c Automation = Automation_Processes__c.getInstance(UserInfo.getUserId());
        
        
    if(!Automation.Bypass_Account_Deletion_trigger__c){
       return;
        }
        
    System.debug(' accountdeleteTrigger');
    for(Account acc : trigger.old){
            acc.adderror('Account Cannot be deleted');
    }

    
}
Maharajan CMaharajan C
Hi Mike,

There is no problem in your code.

Check your custom setting record... Is it marked as true or false... It should be false then your trigger will bypass...

Thanks,
Maharajan.C
Maharajan CMaharajan C
Sorry Mila, I mentoned your name wrongly...