-
How to show error message on the detail page of Salesforce sobject through before delete trigger?
I want to show error message on Account detail page, given below trigger shows error on the different page :-
trigger testDelete on Account (before delete)
{
List <Account> acc = [SELECT Id, (SELECT Id FROM Opportunities ) FROM Account WHERE Id IN : Trigger.old];
for(Account a : acc)
{
if(a.Opportunities.size()>0)
{
Trigger.oldmap.get(a.Id).addError('Cant Delete');
}
}
}
Log In to reply.
Popular Salesforce Blogs

What To Do When Salesforce Apex Heap Size Increases?
Welcome to Salesforce! You've just encountered your first governor limit . The 'Apex heap size too large' error occurs when too much data is being…

Learn About Apex Web Services Unit | Salesforce Developer Guide
Apex Web Service You'll uncover your Pinnacle lesson strategies as a REST or Cleanser web benefit operation. By making your strategies callable through the net,…

Introduction to Queues in Salesforce
Queue! You might have heard this word in Data Structures but do you know Queue in Salesforce? Let’s understand Salesforce Queues in this blog. What…