before delete in salesforce
trigger AccountTrigger on Account (before delete)
{
for(Account a:Trigger.old)
{
//collection of old records[Trigger.old]
a.addError('unable to delete the record');
//a [reference variable name]
//addError method used to display an error message
}
//Displaying an error message if the user is trying to delete an account record from salesforce
}
{
for(Account a:Trigger.old)
{
//collection of old records[Trigger.old]
a.addError('unable to delete the record');
//a [reference variable name]
//addError method used to display an error message
}
//Displaying an error message if the user is trying to delete an account record from salesforce
}
Comments
Post a Comment