-
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
Salesforce Nonprofit Cloud Summer '25 Highlights
The Salesforce Summer ‘25 release is bringing the heat with new features for Nonprofit Cloud! With improvements like volunteer management, Philanthropic Research Topic summaries with…
7 Salesforce Developer Hacks you Haven't Heard of!
Salesforce has been the first choice CRM tool for over ten years, for a good reason. Salesforce is undoubtedly the platform on which you would…
Learn Salesforce Einstein – Chapter 4 (How to check API Usage)
How to check API Usage You can see this page if you have uploaded the key using these steps. You see below sections here: 1. API…