-
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
Useful Salesforce Steps and Instructions
Hello All, Today I am going to provide you a very useful and important set of items that you should always keep handy with you…
Implementing Salesforce Path in Lightning
Salesforce developers use Salesforce Path as a successful visualization tool that helps users as a guide along any particular path to reach a final goal.…
Aura Component Framework and Attributes | All You Need to Know
What is the Lightning Component? A UI framework called component framework is used to create single page applications for desktop and mobile platforms. On the client…