-
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
Apex Replay Debugger - Salesforce Developer Guide
In this blog, we are going to discuss the apex replay debugger. Before starting the discussion about apex replay debugger let’s learn some basic knowledge…
What is Salesforce Net Zero Cloud?
Barely a day goes by without there being something in the news about climate change, sustainability or carbon footprints. It is a major focus for…
How to Override Standard Buttons With Lightning Component?
A Lightning component is required to implement lightning:actionOverride interface to be used to override a standard action on an object. You can override the View,…