• jjatoluna
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

The addError() behavior in a before delete trigger results in a message on the Home tab:

 

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 .Contacts cannot be deleted

 

 

I want it to stay on the same tab as the delete button and display at the top in red like this

 

                              Error: Invalid Data.
Review all error messages below to correct your data.
                      Contacts cannot be deleted

 

Note that addError() in a before insert trigger does put the message in red at the top (when not specifying a field)

 

Here is my simple before delete trigger code:

 

trigger contactDeleteTrigger on Contact (before delete)
{
     for (Contact c: Trigger.old)
     {
         c.addError('Contacts cannot be deleted');
     }
}



The addError() behavior in a before delete trigger results in a message on the Home tab:

 

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 .Contacts cannot be deleted

 

 

I want it to stay on the same tab as the delete button and display at the top in red like this

 

                              Error: Invalid Data.
Review all error messages below to correct your data.
                      Contacts cannot be deleted

 

Note that addError() in a before insert trigger does put the message in red at the top (when not specifying a field)

 

Here is my simple before delete trigger code:

 

trigger contactDeleteTrigger on Contact (before delete)
{
     for (Contact c: Trigger.old)
     {
         c.addError('Contacts cannot be deleted');
     }
}