does someone know how to show an error in an object's listview after a dml operation?
I have written a simple trigger that prevents user to delete closed opportunity
List<Opportunity> opportunities = [select Id, isClosed from Opportunity where id IN: Trigger.oldMap.keySet()]; for (Opportunity opp : opportunities) if((opp.IsClosed ) opp.addError('Closed opportunities cannot be deleted');
It works, but obviously the error message is displayed just in the record detail page. If I try to delete a record from the list view (that it's right what I need) I get: Validation Errors While Saving Record(s) There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger......"
Is there a way to solve this issue without writing a custom visualforce page? Thank you