-
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

Object Level Security in Salesforce | The Salesforce Security Guide
We may provide access to an item in Salesforce at the profile or permissions set level. From the Profile or Permission set level, you may…

Top7 Benefits of Using Salesforce CDP in 2023
Summer ’21 was the relaunch of Customer 360 Audience, which brought Salesforce CDP to the forefront. In previous articles, we explained what a CDP consists…

MFA (Multi-Factor Authentication) in Salesforce
Introduction MFA is a special security feature provided by Salesforce that provides an extra layer of protection against suspicious or unauthorised logins. After enabling the…