-
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
Omni-сhannel in Salesforce: Setting the Standard for Customer Service
Modern consumers demand convenience, connecting with companies from anywhere using smartphones or laptops. The true advantage emerges when customers have multiple options tailored to their…
Salesforce Marketing Cloud: Your One-stop Marketing Solution
The Word-class CRM solution, Salesforce does not leave any room for doubts and connects brands and customers in the best possible way. With multiple cloud…
Why It’s Important To Learn Salesforce In 2021
Salesforce is a popular CRM solution, and that’s normal for all the benefits that it offers. It gives businesses a wide range of tools that…