-
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

Latest Salesforce Commerce Cloud Tools to Enhance Developer Experience
Recently, Salesforce announced some new tools at the National Retail Federation (NRF) 2020 in New York City for boosting the developer experience of Salesforce Commerce…

How Can We Add Global Actions to Salesforce1?
Hello guys, Today we see that how we can add global action in Salesforce1. But first, let’s see brief definition of that what is global…

Salesforce Internet of Things Services
Internet of Things (IoT) has become one of the most popular terms of the leading companies in the market in recent years. Why? Well, because…