-
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
Learn Basics of How To Enhance Consumer Service With Salesforce Chatbots
When a company provides support, customers expect quick responses and resolutions, no matter their channel. Agents can only handle a limited number of cases at…
Salesforce ServiceNow Integration Guide
Table of contents: About Salesforce About ServiceNow Why integrate them? Common Salesforce ServiceNow integration use cases How to choose the best integration tool? How to…
What is the Apex Metadata API? | All You Need to Know
Let’s say that you support multiple orgs, and you’ve created a custom field. You want to add your new field to the page layouts in…