-
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
10 Must-Know Facts About Salesforce Managed Services
What are Salesforce Managed Services? Salesforce Managed Services involve various tasks, starting with the initial setup and ongoing monitoring of a company’s Salesforce solutions to…
5 Industry-Specific Use Cases Where Salesforce Development Services Deliver Maximum Impact
Salesforce, as a leading cloud-based customer relationship management (CRM) platform, is designed to help businesses enhance their sales, marketing, and customer service processes. With over…
Salesforce Einstein AI: Everything you need to know about AI for CRM
Introduction Have you ever wondered how YouTube knows exactly what video you want to watch? Or perhaps you’ve been humming a tune all day, only…