-
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
Salesforce Analytics: Uncovering Actionable Insights for Strategic Decision-Making
Data has become essential to modern organizations in the digital age because it provides unmatched insights into consumer behavior, market trends, and operational efficiency. However,…
Solving Challenges that Come with the Traditional Salesforce Chatbot Model
Digitization is the name of the game and customers are getting used to this. Chatbots are part of almost every organization’s digital journey. They offer…
How Salesforce Lightning can Empower Your Business
For the last 16 years, Salesforce has a consistent look and feel. In 2015, Salesforce launched its new platform, known as Salesforce Lightning. However, Salesforce…