-
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
10 Steps to a Sustainable Salesforce Org
Salesforce is one of the most widely used CRM platforms in the world, enabling organizations to streamline their sales, marketing, and customer service operations. However,…
Unlocking the Potential of Generative AI Without Creating Your Own Language Model (LLM)
Generative AI solutions with groundbreaking capabilities like content creation, text summarization, question answering, document translation, and task completion are in high demand. However, integrating large…
Role of Salesforce Implementation Partners in Data Migration
In today’s fast-paced business world, Salesforce stands out as a key player in customer relationship management and sales automation. Utilizing Salesforce Implementation Services can significantly…