-
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 Integrations - Enterprise Portfolio Considerations
Why Salesforce Integration? What are the Benefits? We live in a world where even the smallest of organizations have multiple systems in their IT Footprint…
Never Miss Another Deal With Salesforce Opportunity Management
Selling is all about seizing opportunities and closing deals quickly and efficiently. This means it’s time to look at what hurdles and challenges actually stop…
Docusign E-Signature in Salesforce | The Integration Guide
Why We Need DocuSign? As there are lots of business needs in which we need to send an email with a document in which users…