-
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 Are Setup and Non-Setup Objects in Salesforce
In this top salesforce blog, we will be discussing what are Setup and Non Setup Objects in Salesforce. Setup and Non-Setup Objects in Salesforce Non-Setup…
Essential Steps for Successful Salesforce Implementation in Your Business
Do you want to drive strong customer relationships and transform your business? Or do you need a tool that aligns customer details and their needs…
How DemandBlue’s Salesforce Revenue Cloud Implementation Helped its Customers to Enhance Sales Pipeline, Quote-to-cash, and ROI
The B2B buying segment has become more dependent on fast and flexible purchasing options rather than the usual buying process. This applied change is evident…