-
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
System Events in Salesforce - Learn All About it Here
The Lightning framework fires system events automatically during component initialization, attribute value changes, rendering, and so on. In their HTML markup, all Components can register…
Agentforce Service Agent: Making Proactive Customer Support Delivery Easier
Companies today don't wait for customers to report issues before taking action. Proactive customer support has become the lifeline of successful enterprises that want to be…
Salesforce Customer Portals Vs. Communities: What to Choose?
When we talk about CRMs or portals the first thing which comes to our mind is Salesforce. They are and have been ruling the industry…