-
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
Best Automation Testing Training in Electronic City, Bangalore
Looking for the Best Automation Testing Training in Electronic City, Bangalore to build a high-growth IT career? Join eMexo Technologies, the Top-Rated Automation Testing Training Institute in Electronic…
How Trailhead Helps People to Learn Salesforce?
Trailhead is Salesforce's free web learning platform committed totally to teach individuals to utilize Salesforce. It provides the user with a guided, learning path with a set of…
Types of Report Formats in Salesforce - All You Need to Know
What are the Report Formats in Salesforce? A Salesforce report is a list of information produced dependent on predefined standards. They can be displayed in…