-
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
Top Salesforce Spring '22 Features in Nonprofit and Education Cloud
Salesforce stays at the top of its game by releasing the latest features for every cloud. Let's have a look at the new Spring '22…
Hiring the Best Salesforce Consultants: What to Look for?
Today's businesses constantly seek innovative ways to streamline operations and improve customer service. Salesforce is a leading CRM (customer relationship management) platform in the market…
Formula Fields and Roll-up Summary Fields Usage in Salesforce
Here We are going to discuss “Formula Fields and Roll-Up Summary in Salesforce”. Let's talk beforehand about my blog. Formula field: We use Formula Fields…