-
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
Assign Permission Set at the User Creation Made Simple: What You Need to Know | Salesforce Guide
Step 1: Create a Permission Set Step 2: Create a Record- Triggered Flow to Assign Permission Set at the time of User Creation Don't forget…
5 Questions That Indicates Your Business Needs Salesforce CPQ
Organizations often struggle to identify opportunities to address every aspect– the what, how, where, and why of their business for better sales. At times, the…
Showcasing the Salesforce Ecosystem
Managing the Company Information with Salesforce Provides the Ultimate Support. Salesforce provides the website visitors, clients, managers, and service agents the required platform that acts…