Insert,update,delete operation with Trigger context variables


Trigger AccountTrigger on Account(before insert,before update,before delete){     //using trigger context variables
    if(Trigger.isInsert&&Trigger.isBefore){         for(Account a:Trigger.new){             a.Email__c='mbnchowdarysfdc@gmail.com';         }             }     else if(Trigger.isUpdate&&Trigger.isBefore){         for(Account a:Trigger.new){             a.Email__c='mandalapubrahmanaidu1993@gmail.com';         }             }
    else{         for(Account a:Trigger.old){             a.addError('You cannot delete a record');         }
            }         }

Comments

  1. that's fine but please add explanation of each step then will be great..

    ReplyDelete

Post a Comment